在tableview中添加UITableViewCellAccessoryDe​​tailDisclosureButton - 初学者

时间:2011-10-13 19:40:01

标签: iphone objective-c xcode

我在UITableViewCellAccessoryDetailDisclosureButton的某些单元格上有一个UITableView,当我滚动表格时,UITableViewCellAccessoryDetailDisclosureButton会出现在不会显示UITableViewCellAccessoryDetailDisclosureButton的单元格上}按钮。有人能告诉我为什么会发生这种情况以及我如何阻止它。

我已输入代码以在以下代码中添加UITableViewCellAccessoryDetailDisclosureButton

if (cell == nil) {

    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

1 个答案:

答案 0 :(得分:2)

在表格视图中委托试试这个:

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    // Replace with your Row/cell check...
    if (indexPath.row % 2) {
        cell.accessoryType = UITableViewCellAccessoryNone;
    } else {
        cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
    } 
}
相关问题