【发布时间】:2012-08-08 17:53:58
【问题描述】:
如果我将 UITableView 作为 UIViewController 的属性,并且我正在使用 [tableView cellForRowAtIndexPath:indexPath] 手动访问特定行的单元格。
在一个方法调用上,我应该期望看到多个调用:
- (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
我的每个 UITableViewCell 都有一个 UITextField,我正在尝试访问其文本数据。
这就是我正在做的事情:
for (int section = 0; ix < countOfSections; ++section)
{
NSInteger countOfRowsInSection = // attained
for (int row = 0; row < countOfRowsInSection; ++row)
{
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row inSection:section];
// the follow call seems to elicit multiple invocations
// on my table delegate's
// - (UITableViewCell *)tableView:(UITableView *)aTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
UITableViewCell *cell = [self.tableview cellForRowAtIndexPath:indexPath];
// Access some custom data
}
}
有没有更好的方法来访问存储在 UITextField 每个 UITableViewCell 中的所有部分和行的所有数据?
【问题讨论】:
标签: ios5 uitableview