【发布时间】:2017-07-17 11:10:43
【问题描述】:
我有 2 个UIViewControllers 并希望在其上有 UINavigationController 和 UINavigationBar 和 UINavigationItem。但是我的代码不起作用..
这是我的代码:
#import "testView1.h"
#import "testView2.h"
@interface testView1 ()
@end
@implementation testView1
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor darkGrayColor];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self];
testView2 *detail = [testView2 new];
[navController pushViewController:detail animated:YES];
}
【问题讨论】:
-
你在用故事板吗?
-
实际上你在这里所做的只是分配并初始化一个导航控制器,它带有一个已经存在于窗口中的 rootview 控制器。这一步不应该在 AppDelegate 中,以获得正确的结果
-
@Subramanian 不,我只是在情节提要中创建 UIViewController 并将其类设置为 testView1
-
@K.R.SaravanaKumar 是的,谢谢。但是怎么办呢?
-
@SaMiGiMiX 你在用 Storyboard 吗?
标签: ios objective-c uinavigationcontroller uinavigationbar uinavigationitem