JohnAnge Kernodle JohnAnge Kernodle - 1 year ago 125
Objective-C Question

UIAlertView button action?

I have an

that shows with this code that asks you to rate the application in the appstore.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Rate on the Appstore!"
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.

Answer Source

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://"]];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download