'UIButton'没有可见的@interface声明选择器'setTitle'。

3

好的,所以我刚开始学习Objective-C,遇到了一个非常随机的错误,不确定它想要指出什么。我在xviewContoller.h中有这个。

@property (weak, nonatomic) IBOutlet UIButton *helloButton;

在xViewController.m文件中,以及

- (IBAction)showAlrt:(id)sender;

在这个页面底部的方法中,使用此方法。
- (IBAction)showAlrt:(id)sender {

    UIAlertView* alert = [[UIAlertView alloc]
                          initWithTitle:@"xxxx"
                          message:@"xxxx"

                          delegate:nil

                          cancelButtonTitle:@"Close"
                          otherButtonTitles:nil];
                          [alert show];

                        [self.helloButton setTitle:@"click"]
                        forState:UIControlStateNormal];
}

我接着得到了这个错误:

'UIButton'没有声明选择器 'setTitle' 的可见 @interface

就像这样 [self.helloButton setTitle.....

请有人帮忙吗。


我认为我的@property设置有问题,但我不确定该改成什么:( - user3894984
1个回答

4
[self.helloButton setTitle:@"click"]
                    forState:UIControlStateNormal];

转换为

[self.helloButton setTitle:@"click" forState:UIControlStateNormal];

我的天啊,只是一个 ] 导致了我的问题 :( 不过还是谢谢 :) - user3894984
我已经习惯了C#和C++,所以这很不同,谢谢。 - user3894984
有没有错误代码的参考指南?我现在有另一个错误,它说线程1:信号SIGABRT。 - user3894984
不,没有错误代码,但有错误消息,它们会告诉你出了什么问题。 - gabbler
我认为这是因为我的Storyboard上有一个文本输入机器人,但它没有连接到任何东西。 - user3894984

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接