2013-04-07 79 views
1

所以我有两个观点,我试图用导航连接。线程1:SIGBART信号

我已经在导航控制器嵌入他们并在故事板创建它们之间的推赛格瑞:

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

如果sigaborts,那么就极有可能的NSException抛出。显示异常消息。另外,这与Xcode无关。 – 2013-04-07 12:03:45

+1

尝试通过转到断点来设置异常断点 - >单击左下角的小加号并添加“异常断点”并再次运行应用程序 – btype 2013-04-07 12:19:56

+0

如果btype正确,则会创建一些控制台输出。你看了控制台吗? – 11684 2013-04-07 12:24:05

回答

6

尝试删除:在你的目标行动:

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

,如果你想使用冒号定义你的方法是这样的:

- (void)buttonClicked:(id)sender 
{ 
    NSLog(@"hello"); 
} 
+2

哇,很好的接收! – 11684 2013-04-07 12:22:36

+0

感谢这工作完美:) – 2013-04-07 17:00:05