uialertview block 回调
来源:互联网 发布:搅拌机品牌 知乎 编辑:程序博客网 时间:2024/06/06 15:42
最近项目中需要对uialertview的选择进行判断然后回调,因此想到了block,网上搜了搜,发现了UIAlertView-Block,觉得很方便,因此分享出来。可能许多人早就用过了,也就不详细说明了,直接上代码。
if(![str isEqual: @"javascript:;"]) { if ([str rangeOfString:@"tel://" options:NSCaseInsensitiveSearch].location != NSNotFound) { UIAlertView *aView = [[UIAlertView alloc] initWithTitle:nil message:@"确认拨打电话:" cancelButtonTitle:@"取消" otherButtonTitles:@"拨打", nil]; [aView show]; [aView setHandler:^(UIAlertView *alert, NSInteger buttonIndex) { [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; } forButtonAtIndex:1]; } else { ShopDetailViewController *ctl = [[ShopDetailViewController alloc] init]; ctl.shopDetailUrl = [dict objectForKey:@"url"]; ctl.shouldHideTabbar = YES; ctl.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:ctl animated:YES]; } }
公共接口,方法较多也选择用delegate进行解耦
iOS有很多例子比如最常用tableViewDelegate,textViewDelegate
异步和简单的回调用block更好
iOS有很多例子比如常用的网络库AFNetwork,ASIHTTP库,UIAlertView类。
都是为了在具体的实现Delegate或Block中再进行处理,属于策略模式,具体算法在具体算法类中实现。
0 0
- UIAlertView使用Block回调
- uialertview block 回调
- UIAlertView + Block
- 利用runtime实现UIAlertView的block回调
- UIAlertView 加Block 扩展
- 为UIAlertView添加block支持
- iOS 中 Block实现UIAlertView
- 为UIAlertView添加block支持
- 给UIAlertView UIActionSheet 添加block支持
- UIAlertView用block方式代替delegate
- iPhone开源系列:UIAlertView-Block
- 给UIAlertView UIActionSheet 添加block支持
- ios--block用法之UIAlertView控件的修改
- 使用第三方的支持Block 的UIAlertView
- 用block将UIAlertView与UIActionSheet统一起来
- 将UIAlertView的按钮点击代理方式改为Block形式
- iOS中设计一个Block代码执行的UIAlertView
- 二十三 ,iOS UIAlertView使用block来实现代理方法;
- Sublime Text 2&3中文乱码
- ios 获取全部照片
- 创造纪录!苹果iPhone单季度销量7450万部
- 去除字符串里的空格,统计空格和其中一个字母的个数及仅去除开始的空格
- Go语言实现堆栈(Stack)
- uialertview block 回调
- 使用Ruby和Twitter来进行数据挖掘
- apue学习第十九天(1)——可重入与线程安全(第十二章)
- VC程序运行时间的测试函数
- ll命令字段所代表的意思
- 十年学会程序设计
- ATL简介
- NumberProgressBar:一个简约性感的数字ProgressBar
- 创建成功的Python项目