0

我想我错过了一些明显的东西。我必须UIAlertView获得应用程序审查,但我无法获得执行任何操作的按钮。我已经打电话给UIAlertViewDelegatein my.h,我也有花药UIAlertview,它只是在 an 上IBAction btn,虽然它只是有 cancel ,但效果很好btn

我尝试给予,alert.tag = 1但没有任何区别,所以我评论了我的第一个UIAlertview,所以我只有一个警报,仍然没有快乐。我想我错过了一些简单的东西。

我也试过alertview.cancelButtonIndexoralertview.firstOtherButtonIndex而不是 0

    -(void)  alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {



    if (buttonIndex == 0) {
        NSLog(@"index 0 ");
    }
    else if (buttonIndex == 1) {
        NSLog(@"index 1 ");
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"www.google.com"]];
        NSUserDefaults *rateApp = [NSUserDefaults standardUserDefaults];
        NSInteger appLaunch = [ rateApp integerForKey:@"appLaunch"];
        appLaunch = 0 ;
        [rateApp setInteger: appLaunch forKey:@"appLaunch"];
    }
    else if (buttonIndex == 2) {
        NSLog(@"index 2 ");
    }
}


- (void)viewDidLoad


{
    [super viewDidLoad];

    //rate app  appLaunch == 5 || appLaunch ==10
    NSUserDefaults *rateApp = [NSUserDefaults standardUserDefaults];
    NSInteger appLaunch = [ rateApp integerForKey:@"appLaunch"];
    if (appLaunch == 1  ) {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Like this app ?" message:@"Why not rate at the app store" delegate:nil cancelButtonTitle:@"No thanks" otherButtonTitles:@"Yes",@"Remind me later", nil];
      //  alert.tag = 1;
        [alert show];
        }

谢谢你的帮助。

4

1 回答 1

1

如果你想调用它的委托方法,AlertViewdelegate应该是self而不是。nil

使用此代码:

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Like this app ?" 
                      message:@"Why not rate at the app store"                                        
                      delegate:self 
                      cancelButtonTitle:@"No thanks" 
                      otherButtonTitles:@"Yes",@"Remind me later", nil];
于 2013-07-20T14:02:26.987 回答