UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
message:@"This is an alert."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"Cancle" style:UIAlertActionStyleDefault handler:nil];
UIAlertAction *cancleAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
NSLog(@"do somting");
}];
[alert addAction:defaultAction];
[alert addAction:cancleAction];
[self presentViewController:alert animated:YES completion:nil];
网友评论