我在应用程序的同一视图中使用界面构建器创建了三个按钮。我希望每个按钮都能执行单独的IBActions,但是当我尝试
时- (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
提供了“未找到'按钮'的方法定义”警告。
我对这种方法做错了什么,或者有更好的方法吗?
答案 0 :(得分:0)
我认为它是一个界面构建器问题,请尝试重新连接IB中的方法