我有2 UIViewController
s,并希望UINavigationController具有UINavigationBar & UINavigationItem对它们。但我的代码不工作..为2个UIViewController创建一个UINavigationController
这里是我的代码:
#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];
}
您使用的故事板? – Subramanian
其实你在这里做的是,你只是分配和初始化一个导航控制器与已经存在于窗口中的rootview控制器。这一步应该不在AppDelegate中,以获得正确的结果 – 2017-07-17 11:26:48
@Subramanian no我只是在故事板中创建UIViewController并将其设置为testView1的类 –