enumerateObjectsUsingBlock的使用问题记录
来源:互联网 发布:淘宝举报中心入口 编辑:程序博客网 时间:2024/05/12 20:24
enumerateObjectsUsingBlock
说明:类似与for in 和for 循坏。效率高,运行时间短。
用法例子:
NSArray *_arData;
_arData = @[@"是1",@"是2",@"是3",@"是4",@"是5",@"是6"];
//block引用内部变量定义规则
__blockfloat h =self.view.frame.size.height*0.7/[_arDatacount];
__blockfloat y = 0.15*self.view.frame.size.height;
[_arDataenumerateObjectsUsingBlock:^(NSString *obj,NSUInteger idx,BOOL *stop)
{
//
...............代码块处理....................(其中obj代表for循坏里面的每个字符串,idx代表索引下标,stop代表结束)
UIView *listV = [[UIViewalloc] initWithFrame:CGRectMake(0, y,self.view.frame.size.width, h)];
[listV setBackgroundColor:[UIColorclearColor]];
UILabel *l = [[UILabelalloc] initWithFrame:CGRectMake(60,0, listV.frame.size.width -60, listV.frame.size.height)];
[l setFont:[UIFontsystemFontOfSize:20]];
[l setTextColor:[UIColorwhiteColor]];
[l setBackgroundColor:[UIColorclearColor]];
[lsetText:obj];
l.userInteractionEnabled =YES;
l.tag = idx;
[listVaddSubview:l];
[self.viewaddSubview:listV];
y += h;
UITapGestureRecognizer *singleTap = [[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapAction:)];
singleTap.numberOfTapsRequired =1;
[laddGestureRecognizer:singleTap];
//
}];
- enumerateObjectsUsingBlock的使用问题记录
- enumerateObjectsUsingBlock 使用 方法 iOS
- enumerateObjectsUsingBlock
- enumerateObjectsUsingBlock
- enumerateObjectsUsingBlock、enumerateObjectsWithOptions、enumerateObjectsAtIndexes、makeObjectsPerfor使用
- Ocloud的使用问题记录
- 使用ListView的问题记录
- linux使用的问题记录
- IOS开发中enumerateObjectsUsingBlock 函数的用法
- for,for-in和enumerateObjectsUsingBlock的比较
- IOS 中 For( ; ; ) For( in ) enumerateObjectsUsingBlock效率问题
- Android使用中一些小问题记录的记录
- [记录]使用sscanf_s遇到的问题
- 关于数据集使用的问题记录
- 记录使用BCB6出现的问题
- 使用vc发现的一些问题记录
- 使用sigprocmask遇到的问题,记录下
- Linux下Weblogic的使用问题记录
- jsp/JSTL/javascript 变量访问
- No Hibernate Session bound to thread, and configuration does not allow creation of non-transactional
- 秒杀系统架构优化思路
- IDA Pro权威指南(第2版)
- JDK安装与环境变量配置(linux)
- enumerateObjectsUsingBlock的使用问题记录
- 项目____JSP中文乱码问题总结
- 严重: Error starting static Resources java.lang.IllegalArgumentException
- iOS Provisioning Profile(Certificate)与Code Signing详解
- Node.js中连接PostgreSql数据库的方法
- opencv2-支持向量机之SVM引导
- android关于代码正确但是运行不显示相应的效果的原因
- Fragment
- 重写equals、hashCode