ios - [self.navigationController pushViewController :ngView animated:YES]; not working

标签 ios objective-c uinavigationcontroller xcode4.6

如果我用

 NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self presentViewController:ngView animated:NO completion:nil];

上面的代码 Controller 将转到 NGViewController 页面。

但是如果我使用这个导航 Controller

NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self.navigationController pushViewController:ngView animated:YES];

Controller 将在同一页面中。

任何人都可以告诉这是什么问题。

最佳答案

你应该使用这段代码

NGViewController *ngView = [[NGViewController alloc]initWithNibName:Nil bundle:Nil];
[self presentViewController:ngView animated:NO completion:nil];

写完这一行之后,你想使用推送 View Controller 进入不同的页面

UINavigationController *navigationController = [[UINavigationController       alloc]initWithRootViewController:ngView];

[self.navigationController pushViewController:navigationController animated:YES];

我希望你能通过这段代码解决这个问题祝你好运

关于ios - [self.navigationController pushViewController :ngView animated:YES]; not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16710675/

相关文章:

ios - 以编程方式从 collectionView Cell didSelectItemAt 推送到新的 ViewController - swift

javascript - 防止整页滚动 iOS

iphone - 如何在 self.view 的属性上设置 lldb 观察点?

ios - iOS 7 UITableViewCell 中与 AutoLayout 冲突的约束

iphone - UITableView cellForRowAtIndexPath 导致滚动缓慢

swift - navigationController?.navigationBar.isUserInteractionEnabled 没有按预期工作

ios - 从 Popover View 中呈现模态视图 Controller

ios - MPMoviePlayerViewController观看后隐藏StatusBar并销毁Frame

ios - Objective-C: block 中的动画

ios - 导航和标签栏 Controller 未显示