·您现在的位置: 江北区云翼计算机软件开发服务部 >> 文章中心 >> 网站建设 >> app软件开发 >> IOS开发 >> AlertView+Block的使用

AlertView+Block的使用

作者:佚名      IOS开发编辑:admin      更新时间:2022-07-23

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

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

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

 1 [[[UIAlertView alloc]initWithTitle:@"提示" message:@"当前网络为移动网络,会产生流量费哦( •̣̣̣̣̣̥́௰•̣̣̣̣̣̥̀ ),是否观看视频?" cancelButtonItem:nil
 2                       
 3                         otherButtonItems:
 4                       [RIButtonItem itemWithLabel:@"不看了" action:^{
 5                         [SingleZHVideoPlayer PRepareForReusePlayer];
 6                     }],
 7                       [RIButtonItem itemWithLabel:@"继续播" action:^{
 8                         [SingleZHVideoPlayer playContent];
 9                     }]
10                       , [RIButtonItem itemWithLabel:@"我是土豪,以后都不要烦我" action:^{
11                         //点播
12                         [SingleZHVideoPlayer playContent];
13                         [ZHAppManager sharedInstance].notAutoAlert2g = ![ZHAppManager sharedInstance].notAutoAlert2g;
14                         [[NSUserDefaults standardUserDefaults]setBool:[ZHAppManager sharedInstance].notAutoAlert2g forKey:isNotAutoAlert2gKey];
15                         
16                     }],nil]show]

 

 

 

 

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

附Git地址

UIAlertView-Blocks