UIActionSheet使用
来源:互联网 发布:深圳java薪水 编辑:程序博客网 时间:2024/06/06 13:12
UIActionSheet是IOS系统提供的选择提示项,效果如下图:
使用很方便,每一项点击都可以在代理中监听到,不用考虑适配问题,代码如下:
UIActionSheet *as = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:@"拍照",@"从手机相册选择", nil]; [as showInView:self.navigationController.view];使用注意点:
1.initWithTitle为初始化方法,参数title表示标题,可以设置成nil不显示
2.cancelButtonTitle为取消按钮,点击后UIActionSheet消失
3.可以更具实际情况自己增加按钮。使用otherButtonTitle是设置
4.如果想使用代理,控制器继承UIActionSheetDelegate,一般实现clickedButtonAtIndex方法即可
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { }else if (buttonIndex == 1) { }}buttonIndex代表点击UIActionSheet的哪一项,然后根据判断写逻辑即可。
5.在某些特殊情况下,UIActionSheet的otherButtonTitles不是固定的,需要根据实际情况变化;我们可以使用如下方法添加:
UIActionSheet *mySheet = [[UIActionSheet alloc] initWithTitle:@"请选择" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil]; NSMutableArray *jlInfos=[FMUserInfo sharedInstance].jlInfos; NSString *rsName=@""; for(FMJlInfo *info in jlInfos){ if(![Tools isBlankString:info.resumeName]){ rsName=info.resumeName; } <span style="color:#ff6666;">[mySheet addButtonWithTitle:rsName];</span> } [mySheet showInView:self.navigationController.view];[mySheet addButtonWithTitle:rsName];即是代码添加方法
0 0
- UIActionSheet 使用
- 使用UIActionSheet
- UIActionSheet使用
- 使用UIActionSheet 弹出UIDatePicker
- UIActionSheet的使用
- UIActionSheet的使用
- UIActionSheet的使用详解
- UIActionSheet 的使用
- UIActionSheet的使用
- iOS UIActionSheet的使用
- UIActionSheet的使用
- ios--UIActionSheet的使用
- ios-UIActionSheet的使用
- UIActionSheet 的使用
- iOS--UIActionSheet详细使用
- [IOS]UIActionSheet的使用
- UIActionSheet的使用
- UIActionSheet的使用
- 25个Java机器学习工具&库
- 067_划分数
- Socket通讯采集推送LED(SER)
- log4erl输出error_logger
- 数据库基础学习----基础概念篇1
- UIActionSheet使用
- QGis二次开发基础 -- 构建图层管理器
- 庖丁解牛之UPack工作原理及实例分析(3)
- Linux "ls -l"文件列表权限详解
- android5.1系统TvSettings为选择项添加背景颜色
- 告别编译运行 ---- Android Studio 2.0 Preview发布Instant Run功能
- Web Services 指南之:Web Services 综述
- 教你快速高效接入SDK——总体思路和架构
- springmvc 疑点(一) 事物处理失效