Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ssh/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何使用按钮从同一视图执行不同的操作?_Ios_Objective C - Fatal编程技术网

Ios 如何使用按钮从同一视图执行不同的操作?

Ios 如何使用按钮从同一视图执行不同的操作?,ios,objective-c,Ios,Objective C,在我的应用程序的同一视图中,我有三个用interface builder制作的按钮。我希望每个按钮都做单独的iBaction,但当我尝试这样做时 - (IBAction)button:(id)sender { if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) { [self.textfield resignFirstResponder];

在我的应用程序的同一视图中,我有三个用interface builder制作的按钮。我希望每个按钮都做单独的iBaction,但当我尝试这样做时

- (IBAction)button:(id)sender {
if([[Reachability reachabilityForInternetConnection] currentReachabilityStatus] == NotReachable) {
    [self.textfield resignFirstResponder];
    self.translation.text = @"Sorry, you need an internet connection to translate.";
}
else {
    // Connected to the internet
    [self.textfield resignFirstResponder];
    NSString *toTranslate = self.textfield.text;
    NSString *url = [NSString stringWithFormat:@"http://www.archives.nd.edu/cgi-bin/wordz.pl?keyword=%@", toTranslate];
    NSURL *translationUrl = [NSURL URLWithString:url];
    NSData *translationHtmlData = [NSData dataWithContentsOfURL:translationUrl];
    TFHpple *translationParser = [TFHpple hppleWithHTMLData:translationHtmlData];
    NSString *translationXpathQueryString = @"/html/body/pre";
    NSArray *translationOutput = [translationParser searchWithXPathQuery:translationXpathQueryString];
    NSString *translatedString = ((TFHppleElement *)translationOutput[0]).firstChild.content;
    self.translation.text = translatedString;
}
}
它在viewcontroller.m的
@implementation
上给出了“未找到“按钮”的方法定义”警告


这个方法有什么不对,或者有更好的方法吗?

我认为这是接口生成器的问题,请尝试从IB重新连接该方法

抱歉,这是一个新方法,但如何操作?转到“连接”选项卡,按该方法旁边的x将其删除,而不是像往常一样重新连接。