Xcode6 添加后退按钮
Xcode 6 add a back button
我一直想弄清楚为什么后退按钮不显示。在我的表格视图(动态填充)中我有
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSString *continent = [self tableView:tableView titleForHeaderInSection:indexPath.section];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
@"Main" bundle:[NSBundle mainBundle]];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:@"EditProfileController"];
[self presentViewController:myController animated:YES completion:nil];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
这有效,我可以打开一个名为 EditProfileController 的视图。在我的 EditProfileController.m 我有这个
#import "EditProfileController.h"
@interface EditProfileController ()
@end
@implementation EditProfileController
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(Back)];
self.navigationItem.leftBarButtonItem = backButton;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Back
{
[self dismissViewControllerAnimated:YES completion:nil]; // ios 6
}
@end
我希望看到后退按钮,但什么也没显示。
这是故事板
您需要将设置视图控制器替换为导航控制器。然后,将设置视图控制器作为导航控制器的根目录。最后,推送编辑视图控制器。
Select settingsViewController 转到 Edit->embed in->navigation controller。并使用协议和委托将数据传递给详细视图
我一直想弄清楚为什么后退按钮不显示。在我的表格视图(动态填充)中我有
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSString *continent = [self tableView:tableView titleForHeaderInSection:indexPath.section];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:
@"Main" bundle:[NSBundle mainBundle]];
UIViewController *myController = [storyboard instantiateViewControllerWithIdentifier:@"EditProfileController"];
[self presentViewController:myController animated:YES completion:nil];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
这有效,我可以打开一个名为 EditProfileController 的视图。在我的 EditProfileController.m 我有这个
#import "EditProfileController.h"
@interface EditProfileController ()
@end
@implementation EditProfileController
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"back" style:UIBarButtonItemStylePlain target:self action:@selector(Back)];
self.navigationItem.leftBarButtonItem = backButton;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)Back
{
[self dismissViewControllerAnimated:YES completion:nil]; // ios 6
}
@end
我希望看到后退按钮,但什么也没显示。
这是故事板
您需要将设置视图控制器替换为导航控制器。然后,将设置视图控制器作为导航控制器的根目录。最后,推送编辑视图控制器。
Select settingsViewController 转到 Edit->embed in->navigation controller。并使用协议和委托将数据传递给详细视图