关于UIAlertController 的一些用法
来源:互联网 发布:淘宝网店手机可以开吗? 编辑:程序博客网 时间:2024/05/18 23:27
1.设置两个UIAlertController
@property (nonatomic,strong)UIAlertController *alert;
@property (nonatomic,strong)UIAlertController *alert2;
2.通过懒加载创建
-(UIAlertController *)alert
{
if (_alert ==nil) {
_alert = [UIAlertControlleralertControllerWithTitle:@"标题"message:@"可以自定义一些提示框"preferredStyle:UIAlertControllerStyleActionSheet];
//UIAlertControllerStyleActionSheet
//UIAlertControllerStyleAlert
/*
UIAlertActionStyleDefault = 0,
UIAlertActionStyleCancel,
UIAlertActionStyleDestructive
*/
UIAlertAction *action1 = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction *action2 = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:nil];
UIAlertAction *action3 = [UIAlertActionactionWithTitle:@"action3"style:UIAlertActionStyleDestructivehandler:nil];
UIAlertAction *action4 = [UIAlertActionactionWithTitle:@"action4"style:UIAlertActionStyleDestructivehandler:nil];
[_alertaddAction:action1];
[_alertaddAction:action2];
[_alertaddAction:action3];
[_alertaddAction:action4];
}
return _alert;
}
- (IBAction)btn1:(id)sender {
显示提示框
[selfpresentViewController:self.alertanimated:YEScompletion:nil];
}
-(UIAlertController *)alert2
{
if (_alert2 ==nil) {
_alert2 = [UIAlertControlleralertControllerWithTitle:@"标题"message:@"可以自定义一些提示框"preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *action1 = [UIAlertActionactionWithTitle:@"取消"style:UIAlertActionStyleCancelhandler:nil];
UIAlertAction *action2 = [UIAlertActionactionWithTitle:@"确定"style:UIAlertActionStyleDefaulthandler:nil];
[_alert2addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {
textField.placeholder =@"密码";
}];
[_alert2addTextFieldWithConfigurationHandler:^(UITextField *_Nonnull textField) {
textField.placeholder =@"账号";
}];
[_alert2addAction:action1];
[_alert2addAction:action2];
}
NSLog(@"----------------->>>");
return_alert2;
}
- (IBAction)btn2:(id)sender {
[selfpresentViewController:self.alert2animated:YEScompletion:nil];
}
- 关于UIAlertController 的一些用法
- UIAlertController的用法
- UIAlertController的用法示例
- UIAlertController的用法
- UIAlertController的用法
- UIAlertController的用法
- UIAlertController的用法
- UIAlertController的用法
- UIAlertController的用法
- 关于UIAlertController的使用
- UIAlertController中TextField的用法
- 关于UIAlertController的使用(swift)
- ios9 xcode7 UIAlertController的常用用法
- 关于数组的一些用法
- 关于system()的一些用法
- 一些 关于 控件的用法
- 关于CListCtrl的一些用法
- 关于const的一些用法
- Zxing二维码开源项目
- Android学习第三天之FrameLayout帧布局
- mac 下的mysql ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock
- Jenkins Ubuntu环境安装启动步骤
- 圆角图片github项目:RoundAngleImageView 【常用】
- 关于UIAlertController 的一些用法
- 关于DP的单调队列优化和斜率优化区别
- 把apk、so等文件,打包到system.img的方法
- cloudstack 创建与删除VM流程
- Android之JSON封装与Javascript解析JSON
- android中图片加载的4种途径和加载方法
- 为什么会文不对题
- alter table新增字段操作究竟有何影响?(下篇)
- mysql 左外连接 右外链接 内连接