ios - 线程 1 : Signal SIGBART

标签 ios objective-c

所以我有两个 View ,我试图与导航连接。

我已将它们嵌入到导航 Controller 中,并在 Storyboard 中创建了它们之间的 push segue:

enter image description here

在第一个 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");
}

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

enter image description here

任何想法如何解决它?我已经没有想法了。我正在使用最新的 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/

相关文章:

ios - 结构体数组在闭包之外不更新

iphone - Apple 应用内购买 - 检索特定地区的价格

IOS:stringByReplacingOccurrencesOfString 不起作用

ios - 在 AppDelegate.m 上设置 label.text

ios - iOS应用程序何时直接进入后台状态?

ios - 是否可能更新等高约束?

ios - 警告 : "This app will not work with future versions of iOS"

带复选框的 iPhone UITableViewCell

iphone - 如何将声音放入数组中?

Objective-C 将对象声明为与我声明的完全不同的类