[英]iphone add view controller as subview
我想显示一个模态视图,但不想使用标准方法,因为它们不允许我按照我的喜好为子视图设置动画。 我尝试了以下代码:
EventsCalendarController *calController = [[EventsCalendarController alloc] init];
calController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:calController animated:YES];
[calController release];
但问题是我想使用一些 animation 来展示它,所以我使用以下代码以及 [UIView beginAnimation] 等...
EventsCalendarController *calController = [[EventsCalendarController alloc] init];
calController.modalPresentationStyle = UIModalPresentationFormSheet;
[self.view addSubview:calController.view];
[calController release];
问题是,每当我从“EventsCalendarController”调用以下代码时,都会出现异常:
- (IBAction)btnClose_TouchUpInside:(id)sender {
[self.view removeFromSuperview];
}
这是一个例外:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType btnClose_TouchUpInside:]: unrecognized selector sent to instance 0x7029d60'
我该如何解决/克服这个问题? 谢谢你。
更新:已解决:我在 GitHub 上找到了以下代码: https://github.com/horaceho/iphone-custom-dialogbox这是一个完整的示例,只需编写很少的代码。 我没有找到原作者,所以我只是链接到代码......
您是否要删除已添加为子视图的日历视图? 如果是这样,那么代码必须是这样的:
[calController removeFromSuperview];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.