objective-c - 如何调用 UItableview 委托(delegate)方法。 tableview什么时候在 "for"循环?

标签 objective-c uitableview

//我在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 时重新加载您的表格。

Custom cell tutorial.

关于objective-c - 如何调用 UItableview 委托(delegate)方法。 tableview什么时候在 "for"循环?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15523214/

相关文章:

objective-c - AFNetworking 2.0 AFHTTPSessionManager : how to get status code and response JSON in failure block?

c - 我怎样才能将 SpaceManager cpShape 存储在类似数组的东西中?

Objective-C:为什么使用非 NSMutable 对象?

ios - 检查下载进度时,检查 "progress == 1.0"可以吗?还是应该>=?

ios - 将日期字符串(2016-04-27T08 :06:07. 531Z)转换为特定日期格式dd.MM.YYYY

ios - TableView 不在 Swift 中注册点击,自定义单元格不显示

ios - 在 UITextView 委托(delegate)事件之前调用的键盘事件

iphone - UITableView 问题 : Keep on getting this runtime error unrecognised selector

iPhone 表格 View 滚动中止 - 无法识别的选择器

swift - 按时间顺序快速排序 Firebase 帖子