接下来的操作,也是避免了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]; }
相关推荐
代码实现代理模式。具体文章简介可以参考博文:http://blog.csdn.net/lovefqing/article/details/8270111
ios设计模式delegate 示例 ,导航功能的两个视图控制器(用push方式从一个窗口推到另一个窗口),第二个窗口创建两个按钮,标题分别为红色和绿色,点相应的按钮弹回前一个窗口,同时前一个窗口的背影色变成按钮标题...
NULL 博文链接:https://ikrboy.iteye.com/blog/2002976
网上也有很多Delegate的Demo,比较乱,感觉不容易看懂。本来一个很简单的问题,大家搞得这么复杂。这个Demo就通俗易懂、简单、实用
delegate、五步曲、调用照相机、切换键盘
iOS之代理(delegate)跨页面传值,与Block夸页面传值效果一样。
iOS 的delegate代码是http://blog.csdn.net/ilikeprograming/article/details/26206075的附件。这份代码有助于新手理解delegate。
如题 源码是xcode4.5 ios6.0 环境写成的 做为基础扫盲 可以学到presentModalViewController 的使用 页面跳转的效果等
IOS的内存管理详解。 Delegate具体详解,使用流程。 Speex的语音压缩技术。 完整详细解读。40页,通俗简单,深入浅出,并有代码示例ppt。
IOS 利用Delegate传值 实现了利用Delegate协议进行传递数据的功能。
现有两个视图(ViewController,ViewController1),从ViewController中带参数跳转到ViewController1,在ViewController1选中数据后带有效数据后退到ViewController中,委托实现上述功能。 可以参考:...
ios app :使用delegate事例
IOS开发delegate Demo
NULL 博文链接:https://dingran.iteye.com/blog/1769545
iOS基础——通知代理之NSNotificationCenter、Delegate
delegate和block是iOS上常用于实现回调的两种机制,Demo将两者进行了简单的归类与对比。
ios socket delegate sqlite实例
ios的delegate虽然很简单,但是搞清楚不容易。本demo简单清晰明了,希望可以帮助到大家。效果图,及其说明如:http://blog.csdn.net/robinson_911/article/details/41900453
简易的delegate示例,很容易明白的···delegate在ios下是很重要的,有时候可能会让你晕晕的··值得一看