Ios 为UITabBarController使用的ViewController实现loadView时setBackgroundColor崩溃

Ios 为UITabBarController使用的ViewController实现loadView时setBackgroundColor崩溃,ios,objective-c,uiviewcontroller,tabbarcontroller,loadview,Ios,Objective C,Uiviewcontroller,Tabbarcontroller,Loadview,我有一个视图控制器,它在appDelegate.m中用作tabBarController的一部分(下面截取了代码) feedViewController中的代码发布在下面,当我从下面的实现中删除加载视图时,应用程序崩溃问题已解决 -(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self=[super initWithNibName:nibNameOrNil bundle:n

我有一个视图控制器,它在appDelegate.m中用作tabBarController的一部分(下面截取了代码)

feedViewController中的代码发布在下面,当我从下面的实现中删除加载视图时,应用程序崩溃问题已解决

-(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
{
}

请帮助我理解为什么会发生这种情况。

在加载视图中调用超级方法

-(void)loadView { [super loadView]; }

希望这能对你有所帮助,祝你好运

你能发布崩溃日志吗?考虑到我是iOS的新手,你能解释一下解决方案背后的概念原因吗?这其中哪一个是最重要的case@rajeshsukumaranloadView方法是视图生命周期中使用的方法之一,因此如果需要重写它,则必须调用super方法以获取完成视图生命周期所需的代码。就是这样:)@rajeshsukumaran请将其标记为正确答案,这样以后就不会禁止您提问:)
-(void)loadView { [super loadView]; }