开发者

UINavigation Back button

HI I am developing an application where the NavigationBar at the top is hidden using this code:

- (void) viewWillAppear:(BOOL)animated
{
    [self.navigationController setNavigationBarHidden:YES animated:animated];
    [super viewWillAppear:animated];
}

This means that once on this page there is no back Button to press to go back which means I have to create an IBAction which makes the view change back to the previous one.

I tried creating the IBAction which I use to go to the next page such as this one:

-(IBAction)switchToGettingHere:(id)sender
{
 if(self.gettingHereViewController == nil)
 {
  GettingHereViewController *gettingHere = [[GettingHereViewController alloc]
             initWithNibName:@"GettingHereView" bundle:[NSBundle mainBundle]];
  self.gettingHereViewController = gettingHere;
  [gettingHere release];
 } 
 [self.navigationController pushViewController:self.gettingHereViewController animated:YES];
}

but that didn't work. Any idea how to make 开发者_StackOverflow社区a button perform the same as the standard back button?


Why not just do (from the controller that doesn't have the navigation bar shown):

-(IBAction)switchToGettingHere:(id)sender
{
 [self.navigationController popViewControllerAnimated:YES];
}

This will pop the currently viewController off the stack and return you from whence you came.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜