如何调用 UItableview 委托方法.当 tableview 处于“for"时环形? [英] How to call UItableview Delegate methods. When tableview is in "for" Loop?

查看:44
本文介绍了如何调用 UItableview 委托方法.当 tableview 处于“for"时环形?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

//我正在for循环中创建tableview.循环一次后,tableview 委托/数据源方法需要调用.但是这里的方法(委托/数据源)在完成循环后调用

// i am creating tableview in for loop. after looping once, tableview delegate/datasource methods needs to call. But here methods(delegate/datasource) are calling after finishing loop

//注意:我正在基于页面在滚动视图中显示所有表格控制器

//Note: i am displaying all tables in scrollview based on page controller

//这是我的代码

for(int i=0; i < 10; i++)
{
table_obj[i] = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 700, 500)];
            table_obj[i].separatorStyle = UITableViewCellSeparatorStyleNone;
            table_obj[i].separatorColor = [UIColor clearColor];
            table_obj[i].delegate = self;
            table_obj[i].dataSource = self;
            table_obj[i].backgroundColor = [UIColor clearColor];
            [scrollview addSubview:table_obj[i]];

            [table_obj[i] reloadData];
}

//仅在第 10 个表中加载数据.并非在所有表中

//data is loading only in 10th table. not in all tables

推荐答案

如果您在此之后重新加载表格,那么它应该可以正常工作.

If you are reloading your table after that, then it should work fine.

我认为您添加的视图,而不是添加到您的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath方法,尝试使用自定义单元格概念.并在您从一个表视图转到另一个表视图时重新加载您的表.

I think the views that your are adding in that, rather than adding that in your - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath mehod, try using custom cell concept. and reload your table whenever you are going from one table view to another tableview.

自定义单元格教程.

这篇关于如何调用 UItableview 委托方法.当 tableview 处于“for"时环形?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆