UIAlertController

来源:互联网 发布:信阳淘宝摄影e 编辑:程序博客网 时间:2024/05/18 13:43

  1.  // 创建UIAlertControlller对象(设置标题,内容,显示风格为Alert或ActionSheet)

  2. UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
  3.                                                                message:@"This is an alert."
  4.                                                         preferredStyle:UIAlertControllerStyleAlert];

  5. // 创建UIAlertAction对象(按钮标题、风格为Default,Cancel以及Destructive 、action执行后续动作
  1. UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
  2.            handler:^(UIAlertAction * action) {}];
  3. // UIAlerController加入Action

  4. [alert addAction:defaultAction];
     // 显示Alert对象
  1. [self presentViewController:alert animated:YES completion:nil];

0 0
原创粉丝点击