action sheet
2015-12-14 11:57
232 查看
#pragma mark - show UIActionSheetDelegate -(IBAction)shows:(id)sender{ UIActionSheet *alert = [[UIActionSheet alloc]initWithTitle:@"title" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"这是哪个button" otherButtonTitles:@"other1",@"other2", nil]; [alert showInView:self.view]; } #pragma mark - UIActionSheetDelegate - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ //获得当前索引按钮的标题 NSString *title = [actionSheet buttonTitleAtIndex:buttonIndex]; NSLog(@"%@",title); }
ios8.0 之后,用这个替换
#pragma mark - show -(IBAction)shows:(id)sender{ // UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"My Title" message:@"show to you" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK",@"Other", nil]; // [alert show]; UIAlertController* alert = [UIAlertController alertControllerWithTitle:nil //nil 这一项就会隐藏 message:@"This is an alert." //nil 这一项就会隐藏 preferredStyle:UIAlertControllerStyleAlert]; // typedef enum UIAlertControllerStyle: NSInteger { // UIAlertControllerStyleActionSheet = 0, //底端出现的 就是 UiActionSheet // UIAlertControllerStyleAlert //对话框 // } UIAlertControllerStyle; UIAlertAction* OKAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { NSLog(@"%@",action.title); }]; UIAlertAction* CancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { NSLog(@"%@",action.title); }]; //addAction 添加 [alert addAction:OKAction]; [alert addAction:CancelAction]; [self presentViewController:alert animated:YES completion:nil]; }
相关文章推荐
- 你的情商很高,只是你没发现而已
- 10021---JavaScript--HTML DOM (文档对象模型)简介
- 线程下载图片的问题
- IOS开发 扫描二维码
- Netcat 命令--网络工具中的瑞士军刀
- Linux系统实现多网段DHCP服务器配置
- C/C++小知识总结之四
- Android中自定义ContentProvider及用法
- RouterOS的DHCP中继代理配置
- 带有指示器的progressbar
- 点击空白处让输入法隐藏的比较好用的方法
- 使用 pm2-web 监控 pm2 服务运行状态
- 利用virt-manager远程linux虚拟机
- C#编程语言
- online_judge_1088
- js学习大法:用好firebug,走遍天下都不怕
- AAndroid系统的启动分析init篇
- 2015.12.14-2015.12.20 大论文计划
- [转]Android 5.0——Material Design详解(动画篇)
- JSP 标准标签库(JSTL)