我希望 UIAlertView 的取消按钮启动应用商店,以便可以更新我的应用。我可以让应用程序启动应用程序商店,但我希望它仅在按下 UIAlertView 的取消按钮时启动。我现在的方式是,当我按下取消按钮时出现此错误:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType alertView:clickedButtonAtIndex:]: unrecognized selector sent to instance 0x1651bd90'
这是我初始化和显示 UIAlertView 的代码:
NSString* updateString = @"Please update the app! Thank you!";
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Please Update" message:updateString delegate:self cancelButtonTitle:@"Update Now" otherButtonTitles:nil];
[alert show];
这是应该处理被按下的取消按钮的函数:
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]];
}
我在包含对象的头文件中写了它遵循 UIAlertViewDelegate 协议。
我在这里做错了什么?