这个代码对我来说很好。你怎么添加
UIViewController
到
UITabBarController
在appDelegate中?不是这样吗?
//appDelegate.h
@property (nonatomic, strong) SomeViewController *viewController;
@property (nonatomic, strong) UITabBarController *tabBarController;
//and synthesize those
//appDelegate.m
self.viewController = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:[NSArray arrayWithObjects:self.viewController, nil];
您可以访问
self.tabBarController
和
self.viewController
通过使用从任何位置驻留在appDelegate中
((AppDelegate *)[UIApplication sharedApplication].delegate)