UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"You've been delivered an alert" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];[alertView show];
self.view.backgroundColor = [UIColor whiteColor];
NSString *message = @"Are you sure you want to open this link in Safari?";UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Open Link" message:message delegate:self cancelButtonTitle:[self noButtonTitle] otherButtonTitles:[self yesButtonTitle], nil];[alertView show];
more samples
// one button alertUIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hello" message: @"Hello Master HaKu!" delegate: self cancelButtonTitle: @"OK" OtherButtonTitles: nil];[alert show];[alert release]; // two buttons alertUIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hello" message: @"Hello Master HaKu!" delegate: self cancelButtonTitle: @"YES" OtherButtonTitles: @"NO", nil];[alert show];[alert release]; // more buttons alertUIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Hello" message: @"Hello Master HaKu!" delegate: self cancelButtonTitle: @"OK" OtherButtonTitles: @"Option1", @"Option2", nil];[alert show];[alert release]; @interface AlertTestViewController : UIViewController@end// alert click implmentation- (void) alertView: (UIAlertView *)alertViewclickedButtonAtIndex: (NSInteger)buttonIndex{ NSLog(@"%d", buttonIndex);}