UIAlertController 用法简介

来源:互联网 发布:易语言2017qq盗号源码 编辑:程序博客网 时间:2024/05/05 15:01

//让数组中所有元素 执行 相同的方法 removeFromSuperview
[_answerView.subviews makeObjectsPerformSelector:
@selector(removeFromSuperview)];

//是否允许用户进行交互
//一旦 view 被禁用,那么他的子view也将不会接收用户交互
_optionView.userInteractionEnabled =
NO;

// iconButton (它是self.view 的子view)放到 view的最前面
[
self.view bringSubviewToFront:_iconButton];

UIAlertController
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:
@"come on!"message:@"you win!"preferredStyle:UIAlertControllerStyleAlert];

//样式:
UIAlertControllerStyleAlert :
提示框
UIAlertControllerStyleActionSheet :
从下面弹出的提示框

//想要显示alertController 必须通过下面的方法:
[
selfpresentViewController:alertController animated:YEScompletion:nil];

//alertController 添加 按钮
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:
@"cancel"style:UIAlertActionStyleCancel handler:^(UIAlertAction *_Nonnull action) {

//当点击这个action的时候,就会回调这个block(代码块)
   
}];

[alertController addAction:cancelAction];

// 注意
UIAlertActionStyleCancel :如果设置action style的时候 出现两个  cancel , 就会导致崩溃

0 0
原创粉丝点击