两个tableview 在同一个页面时,出现自动合并的现象
2013-05-19 18:36
295 查看
问题:两个tableview 在同一个页面时,出现自动合并的现象
问题代码:
原因分析:
通过仔细阅读上述代码,我们可以发现,这两个tableview 用的是同一种类型的cell,所以,建议不同的tableview使用不同的cell
建议修改代码如下:
这样,我们就可以对两个不同的tableview 分比进行编辑和配置了。
问题代码:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellIdetify = @"cell"; UITableViewCell *tvCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdetify] autorelease]; tvCell.selectionStyle = UITableViewCellSelectionStyleGray; tvCell.selectionStyle = NO; //让单元格无法被选中 if (tableView.tag == 1000) { [tvCell addSubview:[arrViews objectAtIndex:indexPath.row]]; return tvCell; }else if (tableView.tag == 2000) { [tvCell2 addSubview:[arrViews2 objectAtIndex:indexPath.row]]; return tvCell2; }else { return 0; } }
原因分析:
通过仔细阅读上述代码,我们可以发现,这两个tableview 用的是同一种类型的cell,所以,建议不同的tableview使用不同的cell
建议修改代码如下:
这样,我们就可以对两个不同的tableview 分比进行编辑和配置了。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView.tag == 1000) { static NSString *cellIdetify = @"cell"; UITableViewCell *tvCell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdetify] autorelease]; tvCell.selectionStyle = UITableViewCellSelectionStyleGray; tvCell.selectionStyle = NO; //让单元格无法被选中 [tvCell addSubview:[arrViews objectAtIndex:indexPath.row]]; return tvCell; }else if (tableView.tag == 2000) { static NSString *cellIdetify2 = @"cell2"; UITableViewCell *tvCell2 = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdetify2] autorelease]; tvCell2.selectionStyle = UITableViewCellSelectionStyleGray; tvCell2.selectionStyle = NO; //让单元格无法被选中 [tvCell2 addSubview:[arrViews2 objectAtIndex:indexPath.row]]; return tvCell2; }else { return 0; } } 发现:当一个页面有两个tableview时,如果这两个tableview 都没有设置边框的话,那么这两个tableview会出现合并的现象。只要为这两个tableview设置边框。和合适的间距。它们就会分开。 如何为tableview设置边框,详见: /article/4696214.html
相关文章推荐
- 合并两个数组,两者重复的删除,单着重复的出现一个。
- 合并两个字符集合为一个新集合,每个字符串在新集合中仅出现一次,函数返回新集合中字符串。
- c语言将字符串中连续出现的空格(两个以上)合并成一个
- 调试台自动多出现一个'' ,我 用uploadify上传图片时,在给页面写入一个返回值为图片名称的变量的值的时候值的前面始终多出现一个''
- 合并两个字符集合为一个新集合,每个字符串在新集合中仅出现一次,函数返回新集合中字符串。
- c语言:printf可以自动把两个字符串合并成一个字符串,并且可以合并多个
- 如果DataGrid的checkbox出现点一个另外自动点另一个现象
- c语言:printf可以自动把两个字符串合并成一个字符串,并且可以合并多个
- 合并两个字符集合为一个新集合,每个字符串在新集合中仅出现一次,函数返回新集合中字符串。 如: s1集合{“while”,”for”,”switch”,”if”,”continue”
- [数据结构]第一次作业:将两个有序线形表合并成一个有序表
- 在一个数组中除两个数字只出现1次外,其它数字都出现了2次
- 求高手指教,我有一个会员登陆文件页面,我想在会员点登陆弹出新窗口,然后自动关闭登陆窗口,就象腾讯2007版的官方会员网站http://my.qq.com上面的那个登陆窗口一样
- 剑指offer2.3.2字符串:有两个排序的数组A1和A2,内存在A1的末尾有足够多的空余空间容纳A2,编写一个函数,将A2合并到A1并排序
- python中如何将两个list合并成一个list,不用for语句
- 已知两个链表head1 和head2 各自有序,请把它们合并成一个链表依然有序。使用非递归方法以及递归方法。
- 在IE下,页面只有一个text的时候,回车将自动submit(转)
- 关于在同一个页面使用多个swiper,多个轮播出现冲突的问题?
- 一个整型数组里除了两个数字之外,其他的数字都出现了两次。 请写程序找出这两个只出现一次的数字。
- 两个字符串合并为一个字符串的各种方法
- 登陆成功后自动跳转到登录页面的前一个页面