我有一个视图控制器,它在 appDelegate.m 中用作 tabBarController 的一部分(代码如下)
self.window=[[UIWindow alloc ]initWithFrame:[[UIScreen mainScreen]bounds]];
UITabBarController *baseTab=[[UITabBarController alloc] init];
self.feedViewController=[[FeedViewController alloc] init];
self.favViewController=[[FavViewController alloc] init];
[baseTab.tabBar setTintColor:[UIColor yellowColor] ];
[baseTab setViewControllers:@[self.feedViewController,self.favViewController]animated:YES];
feedViewController 里面的代码贴在下面,当我从下面的实现中删除loadView时,应用程序崩溃得到了解决
-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self)
{
[self setTitle:@"Feed"];
}
return self;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self.view setBackgroundColor:[UIColor blueColor]];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void)loadView
{
}
请帮助我理解为什么会这样。