线程1:信号SIGABRT

时间:2013-04-07 12:02:25

标签: ios objective-c

所以我有两个观点,我试图用导航连接。

我已将它们嵌入到导航控制器中,并在故事板中创建了它们之间的推送信号:

enter image description here

第一个控制器的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");
}

它编译得很好,我可以在模拟器中运行它,但当我点击导航栏中的按钮,而不是记录“你好”,我得到:

enter image description here

任何想法如何解决?我已经没想完了。我正在使用最新的XCode。

1 个答案:

答案 0 :(得分:6)

尝试删除目标操作中的:

UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(buttonClicked)];

如果你想使用冒号定义你的方法,如下所示:

- (void)buttonClicked:(id)sender
{
    NSLog(@"hello");
}
相关问题