开发者

UIAlert for review page

I am fairly new to iPhone coding and wanted to know if someone can help me.

Have got the code ready so that when the app loads a UIAletView loads and prompts the user to review/rate the application but i have a button called "Never Rate"

I needed help to find out how to code the "never rate" button so what when it is pressed the UI Alert does not load everytime the app is loaded.

This is my code so far:

(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"]];
 }

}


You could store a boolean flag somewhere on disk. Then the next time, you check for neverRate == NO and display the alert accordingly.

You could store this using NSUserDefaults:

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

Then to retrieve it:

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


This is my code so far:

- (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"]]; }

}


Rengers is right

Try using NSUserDefaults

Saving

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

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

[prefs synchronize];

Reading

NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];

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

Check This link

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜