所以我有两个 View ,我试图与导航连接。
我已将它们嵌入到导航 Controller 中,并在 Storyboard 中创建了它们之间的 push segue:
在第一个 Controller 的 viewDidLoad 中,我向导航添加了一个按钮以及单击时应调用的方法:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonClicked:)];
self.navigationItem.rightBarButtonItem = myButton;
}
- (void)buttonClicked
{
NSLog(@"hello");
}
它编译得很好,我可以在模拟器中运行它,但是当我点击导航栏中的按钮时,而不是记录“你好”,我得到:
任何想法如何解决它?我已经没有想法了。我正在使用最新的 XCode。
最佳答案
尝试删除 :
在你的目标行动中:
UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonClicked)];
如果你想使用冒号定义你的方法是这样的:
- (void)buttonClicked:(id)sender
{
NSLog(@"hello");
}
关于ios - 线程 1 : Signal SIGBART,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15862144/