I need to limit the number of multiple selection in a Table View, but I don't have any idea for where can I begin.
Thanks and regards!
I need to limit the number of multiple selection in a Table View, but I don't have any idea for where can I begin.
Thanks and regards!
- (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView.indexPathsForSelectedRows.count > 5)
return nil;
else
return indexPath;
}
Create a NSMutableArray. Whenever someone selects a cell, check the number of items already in the array. If it's less than your limit, put a reference to that cell's backing data into your array. If it has reached its limit, either ignore the selection or replace a previous selection...whichever makes sense for your app.