ios - UIAlertView 按钮 Action ?

标签 ios objective-c delegates uialertview

我有一个 UIAlertView,它显示了这段代码,要求您对应用程序商店中的应用程序进行评分。

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate on the Appstore!" 
                                                message:@"" 
                                               delegate:self 
                                      cancelButtonTitle:@"Later" 
                                      otherButtonTitles:@"OK", nil];
[alert show];
[alert release];

但我不知道如何向将您带到 AppStore 中的应用程序的“确定”按钮添加操作。

最佳答案

这个怎么样?

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex != [alertView cancelButtonIndex]) {
        NSLog(@"Launching the store");
        //replace appname with any specific name you want
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"itms://itunes.com/apps/appname"]];
    } 
}

关于ios - UIAlertView 按钮 Action ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10255455/

相关文章:

iphone - 开发 iPhone 游戏需要什么?

ios - 从数组中的数组访问对象(在模型类中定义)

c# - 语句 "delegates are secure"是什么意思?

ios - 从应用程序委托(delegate)获取当前 View Controller (模态是可能的)

ios - userInteractionEnabled = NO 是什么意思,它是如何工作的?

iOS 如何获取注解选择的索引?

ios - 我如何以编程方式选择日期并显示在 FSCalendar 上

objective-c - 将目录的内容复制到 Documents 目录

iphone - 子类化委托(delegate)?

ios - 带有 TableView 的 subview Controller Nib