开发者

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

开发者 https://www.devze.com 2023-02-13 16:54 出处:网络
my coding is - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { FirstTabBarItem = [[FirstMuseum alloc] init];

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 = @"He开发者_JAVA百科llo";
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 ??????


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消