当我转到另一个视图控制器时,我想要一个后退按钮,但我无法实现这一点。我试图将后退按钮设置为不隐藏,没有运气。一点背景信息,当应用程序启动时没有加载导航控制器,我试图通过一个uiviewcontroller到另一个。
以下是我试图实现这一目标的方法,如果有人能说出错的话......我们将不胜感激!
displayViewController *controller = [[displayViewController alloc] initWithNibName:@"displayViewController" bundle:nil];
UINavigationController *aNavController = [[UINavigationController alloc] initWithRootViewController:controller];
[self presentModalViewController:aNavController animated:YES];
[aNavController release];
[controller release];
答案 0 :(得分:0)
您可以将后退按钮放在viewController中,您可以在其中设置后退按钮
- (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];
}