AlertView + Block 的使用

时间:2023-03-09 06:34:32
AlertView + Block 的使用

  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