Objective c “UIAlertView”没有可见的@Interface声明选择器
错误是:UIAlertview没有可见的@Interface声明选择器“initWithTitle:message:delegate:CancelButtontile:OtherButtontile:”Objective c “UIAlertView”没有可见的@Interface声明选择器,objective-c,Objective C,错误是:UIAlertview没有可见的@Interface声明选择器“initWithTitle:message:delegate:CancelButtontile:OtherButtontile:” - (void) subtractTime; { seconds --; timerLabel.text = [NSString stringWithFormat:@"Time: %i", seconds]; if(seconds == 0) {
- (void) subtractTime;
{
seconds --;
timerLabel.text = [NSString stringWithFormat:@"Time: %i", seconds];
if(seconds == 0)
{
[timer invalidate];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Time is up !"
message: [NSString stringWithFormat: @"You Scored %i points", count]
delegate:self
cancelButtonTitle: @"Play Again?"
otherButtonTitle:nil];
}
}
@end
您的代码中有一个输入错误 应该是:
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Time is up !"
message: [NSString stringWithFormat: @"You Scored %i points", count]
delegate:self
cancelButtonTitle: @"Play Again?"
otherButtonTitles:nil];
请注意,它是OtherButtonTiles,而不是OtherButtonTile。当您看到该消息并且知道该方法应该在那里时,您应该始终非常仔细地查看您的代码:您将方法名称拼写错误。谢谢您,不幸的是,它没有修复主要错误。我不知道这意味着什么,没有可见的@界面UIAlertView@user2602189:否,这会解决您看到的错误。消息告诉您,编译器在类的头中找不到具有该名称的方法,这通常是由于键入错误造成的。如果仍然出现错误,则可能是由于未正确实施修复程序,或者现在遇到了另一个错误。@user2602189如果仍然看到错误,则可能必须使用import手动导入UIKit标头。请注意,UIAlertView通常仅在iOS上可用。如果你正在为Mac开发,你将无法使用它。