I have a UItabbarController and inside the first tab a UINavigationController. In interface builder I have set the tab bar and navigation bar as hidden.
When the first screen loads up (which is a UIVewcontroller in the Uinaviagtioncontroller of the first tab) I set an NStimer for 2 seconds. After which it navigates to a second view. Now when this happens I want the navigation bar and tabbar to appear, and it should be animated.
This what I am doing right now.
First UIViewController:
- (void)viewDidLoad {
[super viewDidLoad];
splashTime = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector (action) userInfo:nil repeats:NO];
}
-(void)action{
SecondViewController *m = [[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil];
[self.navigationController pushViewController:m animated:YES];
}
Second UIViewController:
- (id开发者_JAVA技巧)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
self.hidesBottomBarWhenPushed = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
return self;
}
But nothing is really happening. Neither the Tabbar or the NavigationBar appears.
Try place the code for your Second View Contoller inside the viewWillAppear method instead of the initWithNibName method and see if that has the desired outcome:
- (void) viewWillAppear:(BOOL)animated {
self.hidesBottomBarWhenPushed = NO;
[self.navigationController setNavigationBarHidden:NO animated:YES];
}
That way it should be called everytime the view is about to display.
精彩评论