Add tableView.allowsSelection = false
to didSelectRowAtIndexPath:
and then re-set it to true
at the appropriate time (I'm guessing after your web service stuff completes).
ADDED:
To make it so that the selected row cannot be selected again, I would add
Swift:
var selectedRows = [Int]()
as an instance variable (i.e. at the class level, not within a method).
Then I would change didSelectRowAtIndexPath:
to something like this:
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if !(selectedRows as NSArray).containsObject(indexPath.row) {
// Request data from web service because this row has not been selected before
selectedRows.append(indexPath.row) // Add indexPath.row to the selectedRows so that next time it is selected your don't request data from web service again
let cell = tableView.cellForRowAtIndexPath(indexPath) as UITableViewCell
cell.selectionStyle = UITableViewCellSelectionStyle.None
}
}
Objective-C:
@property (strong, nonatomic) NSMutableArray *selectedRows;
In the view controller, initialize selectedRows
:
- (NSMutableArray *)selectedRows
{
if (!_selectedRows) {
_selectedRows = [[NSMutableArray alloc] init];
}
return _selectedRows;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (![self.selectedRows containsObject:indexPath.row]) {
// Request data from web service because this row has not been selected before
[self.selectedRows addObject:indexPath.row]; // Add indexPath.row to the selectedRows so that next time it is selected your don't request data from web service again
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
}
}