Monday, January 10, 2011

[Basic]AlertView

- (void)viewDidLoad {

    UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Title"
    message:@"Message\nMessage"
    delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", @"Cancel", nil];

    [alertView show];
    [alertView release];
}

- (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1) { // "Cancel" Button, close the alertView;
          // Do something
    } else { // buttonIndex == 0 // "OK" Button;
         // Do something
    }
 }

No comments:

Post a Comment