iOS开发-UIActionSheet和UIAlertController
2016-02-29 00:16
836 查看
ActionSheet
AlertController
- (void)buttonPressed:(id)sender { /** UIActionSheet已经在8.3后被弃用了,如果想要去掉警告信息,可以把项目的Deployment Target设置为8.3以下,就可以去掉警告了。 */ /** Title:如果不想要title,可以设置为nil; 注意需要实现UIActionSheetDelegate; destructiveButtonTitle:设置的按钮文字是红色的; otherButtonTitles:按照按钮顺序; */ UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"这是标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil]; /** * UIActionSheetStyleAutomatic UIActionSheetStyleDefault UIActionSheetStyleBlackTranslucent UIActionSheetStyleBlackOpaque */ //这里的actionSheetStyle也可以不设置; actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic; [actionSheet showInView:self.view]; }
AlertController
- (void)buttonPressed1:(id)sender { NSLog(@"dianji"); // 初始化提示框 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"Message" preferredStyle:UIAlertControllerStyleActionSheet]; [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(@"点击确定"); }]]; [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { NSLog(@"点击取消"); }]]; [self presentViewController:alert animated:true completion:nil]; }
相关文章推荐
- EasyUI文档学习心得
- RESTful Request:GET/PUT/DELETE/POST/HEAD/OPTIONS
- java.lang.Exception: Exception in sending Request :: null
- Android--Handler,Looper,MessageQueue的关系
- WebSphere Message Queue介绍
- 设置UIImage的渲染模式:UIImage.renderingMode
- 获取手机信息(UIDevice、NSBundle、NSLocale)
- 使用Arduino录制与播放遥控器的红外信号
- 笔记:SqueezeNet: AlexNet-level accuracy with 50x fewer parameters and <1MB model size
- UIView属性clipsTobounds的应用
- Jmeter性能测试,MySQL JDBC request
- UIGestureRecognizer
- EasyUI Combobox 级联查询
- npm package.js Guide
- UIControl 的基本使用方法和 Target-Action 机制
- microservice-demo maven build 时报错(A required class is missing: org/codehaus/plexus/util/Scanner)
- UITableview代理方法与Viewcontroller分离
- Dynamic web module 3.0 requires Java 1.6 or newer解决办法
- 4.5.3 Async耗时操作必须由子线程完成,更新UI需要由主线程完成
- UITableView介绍 之 基本用法