0

I have a view controller which is used in appDelegate.m as part of a tabBarController (code snipped below)

 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];

The code inside feedViewController is posted below ,the app crash is solved when I removed the loadView from the below implementation

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

Please help me to understand why this is happening.

1 Answers1

0

call super method in the load view

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

hope this will help you, good luck

ahmedHegazi
  • 190
  • 1
  • 14
  • Considering me as a newbie to iOS could you please explain the conceptual reason behind the solution.Which would be the super in this case – rajesh sukumaran Sep 06 '15 at 15:02
  • 1
    @rajeshsukumaran loadView method is one of the methods used in the life cycle of the view so if you need to override it you must call the super method to get the code needed to complete the view life cycles. that's it :) – ahmedHegazi Sep 06 '15 at 15:07
  • @rajeshsukumaran please mark it as correct answer so you can not be banned from asking question later :) – ahmedHegazi Sep 14 '15 at 13:17