//UIAlertController - 提示框
/**
alertControllerWithTitle - 提示标题
message - 信息
preferredStyle - 类型
UIAlertControllerStyleActionSheet = 0,
UIAlertControllerStyleAlert
*/
UIAlertController *ac = [UIAlertController alertControllerWithTitle:@"提示框" message:@"无法打开.avi" preferredStyle:UIAlertControllerStyleActionSheet];
/**
* @param UIAlertActionStyle
UIAlertActionStyleDefault = 0,
UIAlertActionStyleCancel,
UIAlertActionStyleDestructive - 摧毁的,毁灭的
*/
初始化一个按钮并且加到提示框
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"强制打开" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
//点击按钮之后要执行的东西
}];
//按钮添加到AlertController
[ac addAction:action1];
UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"强制关闭" style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
//点击按钮之后要执行的东西
}];
//按钮添加到AlertController
[ac addAction:action2];
UIAlertAction *action3 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
//点击按钮之后要执行的东西
}];
//按钮添加到AlertController
[ac addAction:action3];
//presentViewController - 出现,显示一个viewController
//animated - 要不要动画效果
把AlertController显示到控制器上
[self presentViewController:ac animated:YES completion:^{
}];
网友评论