我遇到了一个只会定期引发错误的问题.事实上它似乎几乎是随机的.这是发生的事情,我正在使用以下代码启动模态视图控制器: - (void)createMessageClicked{ UIStoryboard *sb = [UIStoryboard storyboa
- (void)createMessageClicked { UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Channel" bundle:nil]; UINavigationController *nav = [sb instantiateViewControllerWithIdentifier:@"HIComposeMessageNavController"]; HIComposeMessageViewController *vc = [[nav viewControllers]objectAtIndex:0]; vc.channel = [self.channels objectAtIndex:0]; [self.navigationController presentViewController:nav animated:YES completion:nil]; }
大多数时候,这很好.然而偶尔应用程序崩溃并引发错误“应用程序试图以模态方式呈现一个活动控制器< UINavigationController>.任何想法我在这里做错了什么?
尝试实例化故事板中导航控制器中嵌入的控制器,然后创建通用导航控制器的新实例:HICompseController *controller = [sb instantiateViewController: HIComposeMessageViewController]; UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:controller]; [self presentViewController:nav animated:YES completion:nil];