-1
我试图从代码创建一个UITableView
(以前从未这样做过),它将显示在UIPopover
中。我想列出目录的内容(仅限文件名)。这是我的代码:如何以编程方式配置UITableViewCell?
- (UITableViewCell *)tableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"FilenameCell";
UITableViewCell *cell = (UITableViewCell *)[theTableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel = fileList[0];
return cell;
}
这显然不工作,我收到一个错误:“分配到只读属性”。所以,问题是:在这种情况下如何设置单元的数据?
'dequeueReusableCellWithIdentifier的转换:'的结果是无用的。 – vikingosegundo 2014-09-12 22:37:37