//图片列表
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 = ;
}
}

  

IOS列表实现动态多列的更多相关文章

  1. ios 开发中 动态库 与静态库的区别

    使用静态库的好处 1,模块化,分工合作 2,避免少量改动经常导致大量的重复编译连接 3,也可以重用,注意不是共享使用 动态库使用有如下好处: 1使用动态库,可以将最终可执行文件体积缩小 2使用动态库, ...

  2. EasyUI datagrid动态生成列

    任务描述:根据用户选择时间段,生成列数据,如图

  3. jQuery EasyUI中DataGird动态生成列的方法

    EasyUI中使用DataGird显示数据列表中,有时需要根据需要显示不同的列,例如,在权限管理中,不同的用户登录后只能查看自己权限范围内的列表字段,这就需要DataGird动态组合列,下面介绍Eas ...

  4. easyui如何动态改变列的编辑属性

    动态改变列的编辑属性 var tt=$('#dg').datagrid('getColumnOption', 'yearContent'); //通过列名获得此列 tt.editor={type:'t ...

  5. jqGrid使用setColProp方法动态改变列属性

    在使用jqGrid插件时,有时我们需要动态改变列的属性,可使用setColProp方法,用法如下 jQuery(”#grid_id”).setColProp('colname',{editoption ...

  6. asp.net gridview动态添加列,并获取其数据;

    1,绑定数据前先动态添加列,见方法CreateGridColumn(只在第一次加载动态添加): 2,gvlist_RowDataBound为对应列添加控件: 前台代码: <%@ Page Lan ...

  7. WPF datagrid 动态增加列

    DataGrid动态增加列 <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.m ...

  8. GridView动态添加列之后,导致PostBack(回发)页面数据丢失问题解决

    直入主题,首先声明,这个问题是无法解决的,特此在这说明 一.如何动态添加列,如下: 在页面重写OnInit事件,至于为什么要在这个事件写,根据页面的声明周期和经验可知(不用去别的地方找了,这个我找了之 ...

  9. 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果

    原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...

随机推荐

  1. asp程序调试

    最近一直在开发asp的接口.调试一个很大的工作量.每次都让人疯狂.asp当中的提取方式时,因为没有智能提示能工具,很容易丢掉参数.而且,因为是弱类型,可以直接定义使用,不强制声明,看似很方便.很容易出 ...

  2. 35.3wCF编程

    1.新建一个空白的解决方案文件,然后添加新建项目,项目类型为WCF服务应用程序,CH35Ex01 2.添加新建控制台应用程序Ch35Ex01Client 3.生成解决方案 4.右键Ch35Ex01Cl ...

  3. [HDOJ5584]LCM Walk(数论,规律)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5584 给一个坐标(ex, ey),问是由哪几个点走过来的.走的规则是x或者y加上他们的最小公倍数lcm ...

  4. Fragment学习(一)

    Fragment界面添加 了解过fragment的生命周期等简单知识,于是去看官方文档来了解更多相关内容,要添加fragment到我们的UI界面中,给出了两种常用的方法,第一个是在activity的布 ...

  5. 《OD学storm》20160827

    http://www.cnblogs.com/lujinhong2/p/4686512.html http://blog.csdn.net/paul_wei2008/article/details/2 ...

  6. HDU 1851 (巴什博奕 SG定理) A Simple Game

    这是由n个巴什博奕的游戏合成的组合游戏. 对于一个有m个石子,每次至多取l个的巴什博奕,这个状态的SG函数值为m % (l + 1). 然后根据SG定理,合成游戏的SG函数就是各个子游戏SG函数值的异 ...

  7. 51nod1201 整数划分

    01背包显然超时.然后就是一道神dp了.dp[i][j]表示j个数组成i的方案数.O(nsqrt(n)) #include<cstdio> #include<cstring> ...

  8. poj2942 Knights of the Round Table 双连通分支 tarjan

    题解:http://blog.csdn.net/lyy289065406/article/details/6756821 讲的很详细我就不多说了. 题目连接:http://poj.org/proble ...

  9. Nginx安全配置

    nginx本身不能处理PHP,它只是个web服务器,当接收到请求后,如果是php请求,则发给php解释器处理,并把结果返回给客户端.nginx一般是把请求发fastcgi管理进程处理,fastcgi管 ...

  10. Jquery源码中的Javascript基础知识(四)— jQuery.fn.init方法

    $() 即调用了jQuery.fn.init方法 jQuery = function( selector, context ) { return new jQuery.fn.init( selecto ...