我提出了一个modalViewController,它实际上是一个带有一个视图的导航控制器,还有一个自定义导航栏。模态视图按预期显示正常,但是当我尝试使用[self dismissModalViewControllerAnimated:YES]将其从视图中删除时,我正在点击“ - [UINavigationController modalViewController]:消息发送到解除分配的实例”。似乎无法弄清楚这一点。有什么想法吗?
实例化ModalViewController:
// Make a navigation controller and add the view inside it
MyViewController *evc=[[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
//UINavigationController *nvc = [[UINavigationController alloc] initWithRootViewController:evc];
UINib *nib = [UINib nibWithNibName:@"UINavigationBarWithBackgroundImage" bundle:nil];
UINavigationController *nvc = [[nib instantiateWithOwner:nil options:nil] objectAtIndex:0];
[nvc setViewControllers:[NSArray arrayWithObject:evc]];
evc.delegate=self;
[evc release];
[self presentModalViewController:nvc animated:YES];
[nvc release];
并尝试将其删除。这就是错误的来源:
[self dismissModalViewControllerAnimated:YES];
答案 0 :(得分:0)
对此不确定,但无论如何都要尝试:
删除
[nvc release]
并查看是否
[self dismissModalViewControllerAnimated:YES];
现在有效。
答案 1 :(得分:0)
你有没有理由加载两个单独的笔尖来显示这个模态?您无需加载包含导航控制器的笔尖即可使其正常工作。
尝试这样的事情:
// Make a navigation controller and add the view inside it
MyViewController *evc= [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:evc];
evc.delegate=self;
[self presentModalViewController:navController animated:YES];
[evc release];
[navController release];