开发者

Adding UITableViewCellAccessoryDetailDisclosureButton in a tableview - beginner

开发者 https://www.devze.com 2023-04-13 09:13 出处:网络
I have a UITableViewCellAccessoryDetailDisclosureButton on some cells in a UITableView, and when i scroll the table, the UITableViewCellAccessoryDetailDisclosureButton gets appeared on cells that were

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

精彩评论

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

关注公众号