这是一个新手问题。我创建了一个分组的tableview。点击它导航到一个新视图的tableview单元格。但我无法创建一个后退按钮。我甚至在笔尖的第二个视图中添加了一个导航栏file.but它没有效果..你们可以帮帮我..下面是第一个视图的截图和代码
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.
if (indexPath.row==0) {
self.dvController1 = [[FirstView alloc] initWithNibName:@"FirstView" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController1 animated:YES];
}
if (indexPath.row==1) {
self.dvController2 = [[Tab4 alloc] initWithNibName:@"Tab4" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController2 animated:YES];
}
}
答案 0 :(得分:0)
在提供的控制器中添加一个带有IBAction
的按钮:
- (IBAction)back:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
确保您确实拥有navigationController
(意味着您的应用程序需要面向导航,这意味着您需要在应用程序委托中实例化navigationController
属性)
答案 1 :(得分:0)
在第二个视图中。在viewDidLoad方法中输入此代码
self.navigationItem.leftBarButtonItem.title = @"Back";
答案 2 :(得分:-1)
只需隐藏viewWillAppear方法中的栏和&取消隐藏tableViewController类的viewWillDisAppear方法中的栏。使用
self.navigationController.navigationBarHidden = YES/NO;