I have an UIAlertView
that shows with this code that asks you to rate the application in the appstore.
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate on the Appstore!"
message:@""
delegate:self
cancelButtonTitle:@"Later"
otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
But I cannot figure out how to add an action to the OK button that takes you to the app in the AppStore.
How about this?
- (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"]];
}
}
You want something like the following:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
NSLog(@"Clicked button index 0");
// Add the action here
} else {
NSLog(@"Clicked button index other than 0");
// Add another action here
}
}
NSLog's appear in the console when you press a button and help out whenever you want to debug/test anything.
Then for the action that you want, you'd write something like:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"url_to_app_store"]];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With