I want to implement tableview in which by default one cell is selected for a particular value and we can select the other cell and the tick mark appear on it. At a single time select a particular cell for particular value.
I want to implement this for the selection of the countries through which we match the particular country API for parsing.
Thanks in advance.
Unless this is an iPad app with a tableview as the left pane, leaving a UITableView with a selected UITableViewCell is against Apple's human interface guidelines. Apple prefers that you use just the tick mark (set the UITableViewCell accessory type to UITableViewCellAccessoryCheckmark) to indicate that the particular row is selected.
Here's some code to get you started:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSArray *visibleCells = [tableView visibleCells];
// Remove checkmark from all visible cells
for (UITableViewCell *aCell in visibleCells) {
aCell.accessoryType = UITableViewCellAccessoryNone;
}
// Now add the tick mark to the selected cell
UITableViewCell *selectedCell = [tableView cellForRowAtIndexPath:indexPath];
selectedCell.accessoryType = UITableViewCellAccessoryCheckmark;
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
Don't forget to set the appropriate accessoryType in your - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath implementation too.
加载中,请稍侯......
精彩评论