本文介绍了以编程方式在uitableview中设置静态单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在以编程方式在目标c中创建一个表格视图.如何通过编程使细胞静态化?
I am programmatically creating a tableview in objective c. How can I make the cells static programmatically?
谢谢
推荐答案
通过为每个单元格使用不同的单元格标识符,您将获得它.您可以使用类似这样的内容:
By using a distinct cell identifier for each one you will get it. You could use something like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = [NSString stringWithFormat:@"s%i-r%i", indexPath.section, indexPath.row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier] autorelease];
//you can customize your cell here because it will be used just for one row.
}
return cell;
}
这篇关于以编程方式在uitableview中设置静态单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!