I wanna know how to check some cells in a table view. Does somebody know how to do that? I want, when the user presses a cell then a checkmark will appear and if the user presses again it ill disappear agian. The user should be available to check more than 1 cell at a time ;)
Asked
Active
Viewed 2,759 times
0
-
I wrote a tutorial for that: http://blog.walkingsmarts.com/creating-radio-button-and-checkbox-lists-using-uitableview/ sorry for the absence of screenshots and the project download .) But the code is there and it works. – Eimantas May 15 '12 at 14:02
-
ill just check it out :) – Mikkel V. May 15 '12 at 14:07
-
Im not good at nib files and old Xcode... Can you please just take all the code i need and paste it here on stack overflow? I'm sorry that i need so much help but I'm really new at Xcode :( – Mikkel V. May 15 '12 at 14:10
1 Answers
1
you can set accessoryType
property of UITableViewCell
to UITableViewCellAccessoryCheckmark
. You just need to keep a BOOL
variable that will let you allow to change between UITableViewCellAccessoryNone
and UITableViewCellAccessoryCheckmark
.
EDIT 1 -
Code for doing so-
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *tableCell = [tableView cellForRowAtIndexPath:indexPath];
BOOL isSelected = (tableCell.accessoryType == UITableViewCellAccessoryCheckmark);
if (isSelected) {
tableCell.accessoryType = UITableViewCellAccessoryNone;
}
else {
tableCell.accessoryType = UITableViewCellAccessoryCheckmark;
}
}

rishi
- 11,779
- 4
- 40
- 59