【问题标题】:iphone add view controller as subviewiphone将视图控制器添加为子视图
【发布时间】:2011-07-11 08:59:30
【问题描述】:

我想显示一个模态视图,但不想使用标准方法,因为它们不允许我按照我的喜好为子视图设置动画。 我试过下面的代码:

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

[self presentModalViewController:calController animated:YES];

[calController release];

但问题是我想使用一些动画来显示它,所以我使用以下代码以及 [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 这是一个完整的示例,只需编写很少的代码。没找到原作者,所以只是链接代码...

【问题讨论】:

    标签: iphone ios4 uiviewcontroller modal-dialog


    【解决方案1】:

    您是否要删除已添加为子视图的日历视图?如果是的话 代码必须是这样的:

    [calController removeFromSuperview];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-05
      • 2016-01-03
      • 1970-01-01
      • 2023-03-11
      • 1970-01-01
      相关资源
      最近更新 更多