Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

what is error "Application tried to push a nil view controller on target <UINavigationController: 0x498efa0>."?

my coding is

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

FirstTabBarItem = [[FirstMuseum alloc] init];
SecondTabBarItem = [[SecondMaps alloc] init];
ThirdTabBarItem = [[ThirdExhibition alloc] init];
FourthTabBarItem = [[FourthTabBarItem alloc] init];


first = [[UINavigationController alloc] initWithRootViewController:FirstTabBarItem];
second = [[UINavigationController alloc] initWithRootViewController:SecondTabBarItem];
third = [[UINavigationController alloc] initWithRootViewController:ThirdTabBarItem];
fourth = [[UINavigationController alloc] initWithRootViewController:FourthTabBarItem];


first.title = @"Hello";
second.title = @"Hello";
third.title = @"Hello";
fourth.title = @"Hello";

myControllerArray = [[NSMutableArray alloc] init];

[myControllerArray addObject:first];
[myControllerArray addObject:second];
[myControllerArray addObject:third];
[myControllerArray addObject:fourth];


myTabBar = [[UITabBarController alloc] init];

[myTabBar setViewControllers:myControllerArray];

localNavigationController = [[UINavigationController alloc] initWithRootViewController:myTabBar];

NSLog(@"Hello, You Tapped !");  }

what is error, I am trying to make a UITabBarController with four item, so now what should I do ??????

Upvotes: 2

Views: 6475

Answers (2)

sureshkumar
sureshkumar

Reputation: 51

yes you can forgot to allocate view controller so try my code:

1) tapaction means button action

_forgotviewcontroller means my second view property eg:

@property (nonatomic,strong) ForgotPassword *forgotviewController;

declared in my firstview

-(void) tapAction:(id)sender
{
    _forgotviewController=[[ForgotPassword alloc]init];
    [self.navigationController pushViewController:self.forgotviewController animated:YES];
}

try this you wil get the navigation

Upvotes: -1

visakh7
visakh7

Reputation: 26400

It means the view controller u r trying to push has not been allocated properly. Pls check the allocation of the view controller and see if its allocated cleanly

Upvotes: 4

Related Questions