开发者

iphone add view controller as subview

I would like to show a modal view but don't want to use the standard methods because they don't let me animate the subview as I like. I tried the fowlloing code:

EventsCalendarController *calController = [[EventsCalendarController alloc] init];
calController.modalPresentationStyle = UIModalPresentationFormSheet;

[self presentModalViewController:calController animated:YES];

[calController release];

but the problem is that I would like to show it using some animation, so I am using the following code along wi开发者_运维问答th [UIView beginAnimation] etc...

EventsCalendarController *calController = [[EventsCalendarController alloc] init];
calController.modalPresentationStyle = UIModalPresentationFormSheet;

[self.view addSubview:calController.view];


[calController release];

The problem is that whenever I call the following code from the 'EventsCalendarController' I get an exception:

- (IBAction)btnClose_TouchUpInside:(id)sender {
    [self.view removeFromSuperview];
}

here is the exception:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType btnClose_TouchUpInside:]: unrecognized selector sent to instance 0x7029d60'

How can I solve/overcome this problem? Thank you.

UPDATE: Solved: I found the following code on GitHub: https://github.com/horaceho/iphone-custom-dialogbox It is a complete example with very few code to write. I did not find the original author, so I am just linking to the code...


Are you trying to remove the calendar view which you have added as a subview ? if so then the code must be like this :

[calController removeFromSuperview];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜