UIAlertController基本使用示例

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];

你可能感兴趣的:(UIAlertController基本使用示例)