AlertView的使用还是很频繁的,扁平化以后似乎也不是那么丑了,但是到现在为止官方还是在用Delegate来处理点击事件,很影响程序的可读性。

如果用Block那么就会一目了然。自己本来想写一个,但是实在是太懒了(其实是不会好吧....)。

  当然,万能的Git上肯定有,轻而易举就找到了,使用方式如下

 [[[UIAlertView alloc]initWithTitle:@"提示" message:@"当前网络为移动网络,会产生流量费哦( •̣̣̣̣̣̥́௰•̣̣̣̣̣̥̀ ),是否观看视频?" cancelButtonItem:nil

                         otherButtonItems:
[RIButtonItem itemWithLabel:@"不看了" action:^{
[SingleZHVideoPlayer prepareForReusePlayer];
}],
[RIButtonItem itemWithLabel:@"继续播" action:^{
[SingleZHVideoPlayer playContent];
}]
, [RIButtonItem itemWithLabel:@"我是土豪,以后都不要烦我" action:^{
//点播
[SingleZHVideoPlayer playContent];
[ZHAppManager sharedInstance].notAutoAlert2g = ![ZHAppManager sharedInstance].notAutoAlert2g;
[[NSUserDefaults standardUserDefaults]setBool:[ZHAppManager sharedInstance].notAutoAlert2g forKey:isNotAutoAlert2gKey]; }],nil]show]

就酱,妈妈再也不用担心我写代理了

附Git地址

UIAlertView-Blocks

  

AlertView + Block 的使用的更多相关文章

  1. 重写AlertView(用block)

    @interface AlertView : UIView @property (nonatomic,copy) void(^block)(UIColor *color); - (id)initWit ...

  2. 使用代理和block写一个alertView

    代理: MyAlertView.h: @property (nonatomic,assign)id delegate; @protocol MyAlertViewDelegate <NSObje ...

  3. ios-自定义alertView提示框

    先上图,弹框的背景色,按钮背景色,提示的消息的字体颜色都可以改变 利用单例实现丰富的自定义接口 // // PBAlertController.h // PBAlertDemo // // Creat ...

  4. BlocksKit初见:一个支持将delegate转换成block的Cocoa库

    简介 项目主页: https://github.com/zwaldowski/BlocksKit BlocksKit 是一个开源的框架,对 Cocoa 进行了扩展,将许多需要通过 delegate 调 ...

  5. 用block响应button的点击事件

    1.继承UIButton : 2.在自己定义的button类中的方法 addTarget:(id)target action:(SEL)action forControlEvents:(UIContr ...

  6. iOS开发技巧系列---使用链式编程和Block来实现UIAlertView

    UIAlertView是iOS开发过程中最常用的控件之一,是提醒用户做出选择最主要的工具.在iOS8及后来的系统中,苹果更推荐使用UIAlertController来代替UIAlertView.所以本 ...

  7. iOS开发——自定义AlertView

    自定义的AlertView,可以选择出现的动画方式,正文信息高度自动变化,特意做了几个可以对比.没啥难点,直接上代码,一看就懂. 1.在YYTAlertView.h文件中 // //  YYTAler ...

  8. 用block将UIAlertView与UIActionSheet统一起来

    用block将UIAlertView与UIActionSheet统一起来 效果 1. 将代理方法的实例对象方法转换成了类方法使用 2. 要注意单例block不要长期持有,用完就释放掉 源码 https ...

  9. 带有关闭按钮的alertView

    概述 由于讨厌系统自带的alertView只能通过点击按钮才能关闭.你说万一按钮区域都是功能性的操作呢(这可不是我胡思乱想哦,要怪就产品的想法吧,呵呵哒),所以我们还是应该备有一个带有“X”(关闭按钮 ...

随机推荐

  1. The Suspects(简单的并查集)

    Description Severe acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, wa ...

  2. 用STRACE解决公司真实故障一例

    这是相关分析文档.为了职业操守,已修改相关公司敏感信息~~~ ~~~~~~~~~~~~~~~~~~~~~~~~ 关于论坛每五分钟左右,会有warning.html跳转出现的原因调查 (warning. ...

  3. C 函数原型

    int add(int,int);//add two int numbers and return it--- add function prototype; int main(int argc, c ...

  4. River Hopscotch(二分)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5473   Accepted: 2379 Description Every ...

  5. Snowflake Snow Snowflakes(哈希,大素数取模)

    Time Limit: 4000MS   Memory Limit: 65536K Total Submissions: 27277   Accepted: 7197 Description You ...

  6. 实战weblogic集群之应用部署

    一.创建应用发布目录,上传应用包. 1.在10.70.52.11-14的/app/sinova目录下建立applications目录(名称可以自定义),作为我们应用的发布目录. $ mkdir /ap ...

  7. 【模拟】Codeforces 707A Brain's Photos

    题目链接: http://codeforces.com/problemset/problem/707/A 题目大意: 给一张N*M的图,只有六种颜色(如下),只含B,W,G的是黑白图,否则是彩色图.问 ...

  8. Delphi TdxComponentPrinter页头页脚的设定

    TdxComponentPrinter页头页脚的设定 抄一段备忘.用程序控制也一样.如果是这样,那么 双击TdxComponentPrinter控件,在出现的窗口中,点击ADD,建立一个与TcxGri ...

  9. 【转】WebStorm 2016 最新版激活(activation code方式)

    作者:=金刚=博客地址:http://www.cnblogs.com/woaic WebStorm 最新版本激活方式:今天下载最新版本的WebStorm,发现原来的通过license server激活 ...

  10. Xamarin开发教程如何使用Xamarin开发Android应用

    Xamarin开发教程如何使用Xamarin开发Android应用 如何使用Xamarin开发Android应用 在了解了Xamarin和Andriod系统之后,下面我们需要了解一下如何使用这些工具和 ...