Wednesday, 14 December 2011

Alert View and Dismiss with button index-iPhone

UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"Wrong Answer.." message:@"SORRY..!!!" delegate:self cancelButtonTitle:@"Next Question" otherButtonTitles:nil,nil];
        [alert show];
        [alert release];



- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex{
   
    // The first button (or cancel button)
    if (buttonIndex == 0) {
       
        NSLog(@"%@ Pressed cancel", [alertView buttonTitleAtIndex:0]);
       
        [self.navigationController popViewControllerAnimated:YES];
    }   
   
    // The second button on the alert view
    if (buttonIndex == 1) {
       
        NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/us/app/iratedphrase/id431595350?mt=8&ls=1"];
       
        if (![[UIApplication sharedApplication] openURL:url])
           
            NSLog(@"%@%@",@"Failed to open url:",[url description]);
    }
   
}

No comments:

Post a Comment