//我在for 循环 中创建 TableView 。循环一次后,tableview 委托(delegate)/数据源方法需要调用。但是这里的方法(委托(delegate)/数据源)在完成循环后调用
//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 个表中加载。不在所有表格中
最佳答案
如果您在那之后重新加载表格,那么它应该可以正常工作。
我认为您在其中添加的 View ,而不是在您的 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
中添加的 View
mehod,尝试使用自定义单元概念。并在您从一个表格 View 转到另一个表格 View 时重新加载您的表格。
关于objective-c - 如何调用 UItableview 委托(delegate)方法。 tableview什么时候在 "for"循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15523214/