您的位置:首页 > 产品设计 > UI/UE

UIAlertController 用法简介

2016-04-10 23:50 453 查看


//

让数组中所有元素
执行
相同的方法
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 必须通过下面的方法:

[self
presentViewController:alertController animated:YES
completion:nil];

//为alertController 添加 按钮

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"cancel"
style:UIAlertActionStyleCancel handler:^(UIAlertAction *

_Nonnull
action) {

//

当点击这个action

的时候,

就会回调这个block(代码块)

   

}];

[alertController addAction:cancelAction];

// 注意

UIAlertActionStyleCancel :
如果设置action style
的时候
出现两个  cancel ,
就会导致崩溃
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: