UIAlert审查页面

时间:2010-09-30 18:41:00

标签: iphone objective-c uialertview

我对iPhone编码很新,想知道是否有人可以帮助我。

已准备好代码,以便当应用程序加载UIAletView时加载并提示用户查看/评价应用程序,但我有一个名为“从不评价”的按钮

我需要帮助来了解如何编写“永不率”按钮的代码,以便在按下时,每次加载应用时都不会加载UI警报。

到目前为止,这是我的代码:

(void)viewDidLoad {


 UIAlertView *alert;
 alert = [[UIAlertView alloc] initWithTitle:@"Rate My Appication" message:@" Please Rate my Application and check out my other Apps" 
           delegate: self 
        cancelButtonTitle:@" Cancel " 
        otherButtonTitles: @" Rate Now ", @"Check Other Apps", @" Never Rate ", nil];

 [alert show];
 [alert release];
}

(bool)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

 // Never Review Button
 if (buttonIndex == 3)
 {


 }

 // Review Button 
 else if (buttonIndex == 1)
 {
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/gb/app/calculator/id389197581?mt=8"]];
 }

 // Other Apps Button 
 else if (buttonIndex == 2)
 {
  [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.com/apps/2headsolutions"]];
 }

}

3 个答案:

答案 0 :(得分:6)

您可以在磁盘上的某处存储布尔标志。然后,下次您检查neverRate == NO并相应地显示警报。

您可以使用NSUserDefaults存储此内容:

[[NSUserDefaults standardDefaults] setBool:YES forKey:@"neverRate"];

然后检索它:

BOOL neverRate = [[NSUserDefaults standardDefaults] boolForKey:@"neverRate"];
if(neverRate != YES) {
  //Show alert here
}

答案 1 :(得分:0)

到目前为止,这是我的代码:

- (void)viewDidLoad {

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate My Appication" 
                                                message:@" Please Rate my Application and check out my other Apps" 
                                               delegate:self 
                                      cancelButtonTitle:@" Cancel " 
                                      otherButtonTitles: @" Rate Now ", @"Check Other Apps", @" Never Rate ", nil];

    [alert show];
    [alert release];
}

- (bool)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    // Never Review Button if (buttonIndex == 3) {

    //}

// Review Button else if (buttonIndex == 1) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.apple.com/gb/app/calculator/id389197581?mt=8"]]; }

// Other Apps Button else if (buttonIndex == 2) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://itunes.com/apps/2headsolutions"]]; }

}

答案 2 :(得分:0)

Rengers是对的

尝试使用NSUserDefaults

保存

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

// saving a BOOL
[prefs setBool:BOOL_var forKey:@"RATE_KEY"];

[prefs synchronize];

阅读

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

// getting a BOOL
BOOL var = [prefs boolForKey:@"RATE_KEY"];

Check This link