我有一个在appDelegate中使用的视图控制器。作为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
{
}
请告诉我为什么会这样
在load view中调用super method
-(void)loadView { [super loadView]; }
希望这对你有帮助,祝你好运