0

当我转到另一个视图控制器时,我想要一个后退按钮,但我无法实现这一点。我试图将后退按钮设置为不隐藏,但没有运气。一点背景信息,应用程序启动时没有加载导航控制器,我试图通过一个 uiviewcontroller 到另一个。

这是我尝试实现这一目标的方法,如果有人能说出问题所在......将不胜感激!

displayViewController *controller = [[displayViewController alloc] initWithNibName:@"displayViewController" bundle:nil];
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:controller];

[self presentModalViewController:aNavController animated:YES];

[aNavController release];
[controller release];
4

1 回答 1

0

您可以将后退按钮放在您想要后退按钮的视图控制器中

- (void)viewDidLoad
{

 // back button 
 UIImage* image = [UIImage imageNamed:@"back.png"];
 CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
 UIButton *backButton = [[UIButton alloc] initWithFrame:frame];
 [backButton setBackgroundImage:image forState:UIControlStateNormal];
 [backButton addTarget:self action:@selector(backAction:) forControlEvents:UIControlStateHighlighted];

UIBarButtonItem* backButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];
self.navigationItem.leftBarButtonItem = backButtonItem;
[backButtonItem release];
[backButton release];
}

-(void) backAction:(id)sender
{
   [self.navigationController popViewControllerAnimated:YES];
}
于 2012-07-30T06:03:10.797 回答