![](/img/trans.png)
[英]Updating a NSMutableArray in new viewController that's pushed onto the stack
[英]Viewcontroller not getting pushed to stack
我对 iPhone 相当陌生。 我有一个奇怪的问题。 我正在添加一个视图控制器作为当前视图的子视图。 然后我想从中推送一个新的视图控制器。 问题是当我尝试执行 pushViewController 时,它没有响应。
例如,在 CurrentViewController 中,我添加了 NewViewController 的视图作为 subView
[self.view addSubView : NewViewController.view]
现在从 NewViewController,单击一个按钮,我正在执行以下操作:
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
这里 secondVC 不会被推入堆栈。
如果您使用过基于视图的应用程序,则必须使用此代码。
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
// [self.navigationController pushViewController:secondVC animated:YES];
[self presentModalViewController:secondVC animated:YES];
如果你想在你的应用程序中使用导航控制器。 首先,您必须在 appln 中添加导航控制器,然后才能导航视图。
也许问题在于该方法被称为pushViewController
而不是pushToViewController
。 尝试
SecondViewController *secondVC = [SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:secondVC animated:YES];
// don't forget release here
[secondVC release];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.