开发者

Adding UITableViewCellAccessoryDetailDisclosureButton in a tableview - beginner

I have a UITableViewCellAccessoryDetailDisclosureButton on some cells in a UITableView, and when i scroll the table, the UITableViewCellAccessoryDetailDisclosureButton gets appeared on cells that were not suppose to display the UITableViewCellAccessoryDetailDisclosureButton button. Can someone tell me why this is happening and how i could prevent it.

I have entered the code to add the UITableViewCellAccessoryDetailDisclosureButton in the following code:

if (cell == nil) {

    cell =开发者_如何学C [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];


In the table views delegate try this:

- (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;
    } 
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜