//图片列表
NSMutableArray *pictureList;
//分组列表
NSMutableArray *indexArr;
 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *picWallItemView = @"picWallItemView";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:picWallItemView];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectMake(, , self.view.frame.size.width, [self tableView:self.tableView heightForRowAtIndexPath:indexPath])] autorelease];
}
int num = [[indexArr objectAtIndex:indexPath.row] intValue];
int index = ;
for (int i = ; i < indexPath.row; i++) {
index += [[indexArr objectAtIndex:i] intValue];
} float tmpWidth = self.view.frame.size.width / num;
float tmpHeight = [self tableView:self.tableView heightForRowAtIndexPath:indexPath];
float left = ;
for (int i = ; i < num; i ++) {
left = i * tmpWidth;
PicWallItemView *itemView = [[PicWallItemView alloc] initWithFrame:CGRectMake(left, , tmpWidth, tmpHeight)];
itemView.delegate = self;
NSDictionary *jsonDic = [pictureList objectAtIndex:index];
PicWallItemTo *item = [PicWallItemTo fromDictionary:jsonDic];
[itemView setIndentationWidth:];
[itemView reloadData:item];
[cell addSubview:itemView];
[itemView setFrame:CGRectMake(left, , tmpWidth, tmpHeight)];
[itemView release];
index++;
}
return cell;
}

在接收数据的地方,对数据进行分组。

         NSArray *arr = [obj objectForKey:MSG_DETALIST];

         NSUInteger total = [arr count];
while (total > ) {
int num = arc4random() % + ;
if(total > num){
[indexArr addObject:[NSNumber numberWithInt:num]];
total -= num;
} else {
[indexArr addObject:[NSNumber numberWithInt:total]];
total = ;
}
}

  

最新文章

  1. HTML中的select只读
  2. java调用Linux命令报错:java.io.IOException: Cannot run program &quot;ps&quot;: CreateProcess error=2, ?????????
  3. 2015年百度之星初赛(1) --- D KPI
  4. HTTP基础(一):如何使用浏览器network查看请求和响应的信息
  5. DedeCms 5.x 本地文件包含漏洞(respond方法)
  6. git 初次使用
  7. 05---JSON学习(Java)
  8. Android开源项目发现--- 效率开发工具篇(持续更新)
  9. SQL Server 2008中数据压缩
  10. Nmap Snote
  11. 64位调试器花费的时间比预期的要长(A 64-bit debugging operation is taking longer than expected)
  12. Moq &amp; RhinoMocks
  13. 河南多校大一训练赛 D
  14. 课堂博客-----TreeView+++++XML形成博客
  15. POJ 2359 Questions(约瑟夫环——数学解法)
  16. 跟我学ASP.NET MVC之二:第一个ASP.NET MVC程序
  17. SOUI新组件SIpcObject介绍
  18. python + PyQt5 实现 简易计算器
  19. XGBOOST应用及调参示例
  20. 自学Aruba3.2-Aruba配置架构-Virtual AP配置要点

热门文章

  1. Zend13.0 +XAMPP3.2.2 调试配置
  2. 360每日自动签到,领取积分 (java httpclient4.x)
  3. leetcode:Rotate List
  4. ajax请求(二),后台返回的JSon字符串的转换
  5. [转]深入hibernate的三种状态
  6. 8皇后以及N皇后算法探究,回溯算法的JAVA实现,非递归,循环控制及其优化
  7. bzoj4199
  8. 代码开光,Orz
  9. POJ 2084 Game of Connections
  10. Qt 获取usb设备信息 hacking