I am new to iOS, i am using Xcode 4.3.2, and i have created a project with tabView, where by default it has two view controllers. I am creating a new one now,
ThirdView.h
#import <UIKit/UIKit.h>
@interface ThirdView : UIViewController
@end
#import "ThirdView.h"
@implementation ThirdView
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
self.title = NSLocalizedString(@"Third", @"Third");
self.tabBarItem.image = [UIImage imageNamed:@"Third"];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
@end
and in the appDelicate.m
viewController3 = [[ThirdView alloc] initWithNibName:@"ThirdView" bundle:nil];
and added viewController3 to tabBarController.
self.tabBarController.viewControllers = [NSArray arrayWithObjects:viewController1, viewController2, viewController3 ,nil];
The Problem is:
When i execute the code in the device, i could see the third tab, but the moment i click, it crashes.
Where i am doing wrong ?
Double check the class name of the third view controller in you nib file.