【发布时间】:2014-05-06 14:54:01
【问题描述】:
我有一个连接到导航控制器的视图控制器。我想在顶部的导航栏上添加一个右键,它将推动另一个视图控制器。如果我添加右键:
UIBarButtonItem *Button = [[UIBarButtonItem alloc] initWithTitle:@"Map" style:UIBarButtonItemStylePlain target:self action:[self forward]];
self.navigationItem.rightBarButtonItem = Button;
按钮出现。但是,如果我在 forward 方法中添加以下几行,按钮会再次消失:
MapViewController *viewController = [self.navigationController.storyboard instantiateViewControllerWithIdentifier:@"map"];
[self.navigationController pushViewController:viewController animated:YES];
这样做的正确方法是什么?
【问题讨论】:
-
删除此操作:[self forward] 并尝试操作:@selector(forward)
-
MapViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"map"]; [self performSegueWithIdentifier:@"map" sender:self];然后在forward方法中编写这段代码
标签: ios cocoa-touch