IOS列表实现动态多列
、
//图片列表
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列表实现动态多列的更多相关文章
- ios 开发中 动态库 与静态库的区别
		
使用静态库的好处 1,模块化,分工合作 2,避免少量改动经常导致大量的重复编译连接 3,也可以重用,注意不是共享使用 动态库使用有如下好处: 1使用动态库,可以将最终可执行文件体积缩小 2使用动态库, ...
 - EasyUI     datagrid动态生成列
		
任务描述:根据用户选择时间段,生成列数据,如图
 - jQuery EasyUI中DataGird动态生成列的方法
		
EasyUI中使用DataGird显示数据列表中,有时需要根据需要显示不同的列,例如,在权限管理中,不同的用户登录后只能查看自己权限范围内的列表字段,这就需要DataGird动态组合列,下面介绍Eas ...
 - easyui如何动态改变列的编辑属性
		
动态改变列的编辑属性 var tt=$('#dg').datagrid('getColumnOption', 'yearContent'); //通过列名获得此列 tt.editor={type:'t ...
 - jqGrid使用setColProp方法动态改变列属性
		
在使用jqGrid插件时,有时我们需要动态改变列的属性,可使用setColProp方法,用法如下 jQuery(”#grid_id”).setColProp('colname',{editoption ...
 - asp.net gridview动态添加列,并获取其数据;
		
1,绑定数据前先动态添加列,见方法CreateGridColumn(只在第一次加载动态添加): 2,gvlist_RowDataBound为对应列添加控件: 前台代码: <%@ Page Lan ...
 - WPF datagrid 动态增加列
		
DataGrid动态增加列 <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.m ...
 - GridView动态添加列之后,导致PostBack(回发)页面数据丢失问题解决
		
直入主题,首先声明,这个问题是无法解决的,特此在这说明 一.如何动态添加列,如下: 在页面重写OnInit事件,至于为什么要在这个事件写,根据页面的声明周期和经验可知(不用去别的地方找了,这个我找了之 ...
 - 【转】提示框第三方库之MBProgressHUD iOS toast效果 动态提示框效果
		
原文网址:http://www.zhimengzhe.com/IOSkaifa/37910.html MBProgressHUD是一个开源项目,实现了很多种样式的提示框,使用上简单.方便,并且可以对显 ...
 
随机推荐
- Ubuntu Server搭建svn服务以及迁移方法【转】
			
转自:http://www.linuxidc.com/Linux/2013-05/84693.htm Ubuntu Server搭建svn服务以及迁移方法 采用apache+svn,http访问方式. ...
 - java.lang.NoSuchFieldError: VERSION_2_3_0 报错解决方案
			
java.lang.NoSuchFieldError: VERSION_2_3_0 at org.apache.struts2.views.freemarker.FreemarkerManager.c ...
 - iPhone(iOS设备) 无法更新或恢复时, 如何进入恢复模式
			
在更新或恢复 iPhone 时,如果遇到以下所列问题之一.可能就要将设备置于恢复模式,并尝试重新恢复设备. 设备不断地重新启动,但从未显示主屏幕. 无法完成更新或恢复,且 iTunes 不再能识别设 ...
 - Python 优雅的操作字典【转】
			
Python 中的字典是Python中一个键值映射的数据结构,下面介绍一下如何优雅的操作字典. 1.1 创建字典 Python有两种方法可以创建字典,第一种是使用花括号,另一种是使用内建 函数dict ...
 - hdu - 2216 Game III && xtu 1187 Double Maze (两个点的普通bfs)
			
http://acm.hdu.edu.cn/showproblem.php?pid=2216 zjt和sara在同一个地图里,zjt要去寻找sara,zjt每移动一步sara就要往相反方向移动,如果他 ...
 - [转]C#中的?和??
			
原文链接:http://msdn.microsoft.com/zh-tw/library/2cf62fcy%28VS.80%29.aspx 使用可為 Null 的型別 (C# 程式設計手冊) Visu ...
 - (转载)C语言 数组与指针的区别
			
1) 字符串指针变量是个变量,指向字符串的首地址:而字符串数组名是个常量,为字符串数组第一个元素的地址: 2)字符串指针变量可以赋值,而字符串数组名不能赋值:对于字符数组只能对各个元素赋值,不能用以下 ...
 - [反汇编练习] 160个CrackMe之021
			
[反汇编练习] 160个CrackMe之021. 本系列文章的目的是从一个没有任何经验的新手的角度(其实就是我自己),一步步尝试将160个CrackMe全部破解,如果可以,通过任何方式写出一个类似于注 ...
 - mysql二
			
日期 MONTHNAME(birth) 月份的英文 模式匹配 变量 统计
 - 20160207.CCPP体系详解(0017天)
			
程序片段:01.Point.c+02.进程.c+03.内存的栈和堆.c 内容概要:内存32位和64位的区别 ///01.Point.c #include <stdio.h> #includ ...