2015-09-06 32 views
0

我有其在appDelegate.m用作setBackgroundColor崩潰時的loadView實施了的ViewController用於的UITabBarController

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的代碼發佈(下面剪斷代碼)的tabBarController 一部分的視圖控制器下面,應用程序崩潰解決我從下面的執行刪除的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 
{ 
} 

請幫我理解爲什麼會發生這種情況。

+0

你能不能請張貼崩潰日誌? –

回答

0

調用加載視圖

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

希望這會幫助你超級方法,好運

+0

考慮到我作爲iOS的新手可以請你解釋解決方案背後的概念原因。在這種情況下,超級將會是 –

+1

@rajeshsukumaran loadView方法是視圖生命週期中使用的方法之一,所以如果你需要覆蓋它,你必須調用超級方法來獲得完成視圖生命週期所需的代碼。這就是它:) – ahmedHegazi

+0

謝謝。它工作 –