Return to Snippet

Revision: 45801
at May 9, 2011 01:31 by bethjt1220


Initial Code
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
       
    if(_lastIndex != nil)
    {
        UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:_lastIndex];
        if(oldCell.accessoryType == UITableViewCellAccessoryCheckmark)
        {
            oldCell.accessoryType = UITableViewCellAccessoryNone;
        }
    }
    
    UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
    if(newCell.accessoryType == UITableViewCellAccessoryNone) {
        newCell.accessoryType = UITableViewCellAccessoryCheckmark;
    }

    _lastIndex = indexPath;
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}

Initial URL


Initial Description
Only allows one table view cell to be checked.

Initial Title
IOS UITableView Check One Cell

Initial Tags
ios

Initial Language
iPhone