IOS之操作表ActionSheet(免Delegate)
2014-01-12 13:49
405 查看
接下来的操作,也是避免了Delegate的写法,方便对不同ActionSheet的分层操作。
1.添加头文件。文件可在附件下载。具体资料请参考:https://github.com/emenegro/action-sheet-blocks#readme
#include "UIActionSheet+Blocks.h"
2.添加如下的方法。(自定义UIButton的单击触发事件)
- (IBAction)showActionSheet:(UIButton *)sender forEvent:(UIEvent *)event { UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Test" delegate:nil // Can be another value but will be overridden when showing with handler. cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"Option 1", @"Option 2", nil]; [sheet showInView:self.view handler:^(UIActionSheet *actionSheet, NSInteger buttonIndex) { if (buttonIndex == [actionSheet cancelButtonIndex]) { NSLog(@"Cancel button index tapped"); } else if (buttonIndex == [actionSheet destructiveButtonIndex]) { NSLog(@"Destructive button index tapped"); } else { NSLog(@"Button %i tapped", buttonIndex); } }]; sheet.actionSheetStyle = UIActionSheetStyleAutomatic; [sheet showInView:self.view]; }
相关文章推荐
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- IOS中操作表ActionSheet
- IOS中的通知--操作表ActionSheet和警报AlertView
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- IOS中的通知--操作表ActionSheet和警报AlertView
- Iphone开发(六)IOS中的通知--操作表ActionSheet和警报AlertView
- [ios]自定义的ActionSheet
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- react native ActionSheetIOS 使用详解
- 警告框和操作表(ActionSheet)
- iOS通讯模式(KVO、Notification、Delegate、Block、Target-Action的区别)
- IOS学习笔记(九)之UIAlertView(警告视图)和UIActionSheet(操作表视图)基本概念和使用方法
- React Native——ActionSheetIOS
- 【原】东方耀REACT-NATIVE学习43,ios日期组件 ActionSheetIOS
- 自定义仿iOS的ActionSheet底部Dialog的样式
- IOS之CustomActionSheet
- ios自定义选择器ActionSheetPicker改进版
- iOS增强版的UIDatePicker,省 市 县三级联动地址选择器(ActionSheetCustomPicker)
- Ios精品源码,扁平化的ActionSheet仿花椒截屏demo文件签名重叠卡片滚动汽车仪表盘