My app calls a block in tableView:didSelectRowAtIndexPath and in the block it presents a view controller. If I click the cell second time when the first click is in progress, it crashes. I've solved the problem using
tableView.userInteractionEnabled = NO;
as answered in my previous question.
It solved multiple clicking problem with table but there is another problem. I'm using ECSlidingViewController. User is able to swipe the page and select a new page from side menu while tableView:didSelectRowAtIndexPath still trying to open another page. I tried to use
[self.view setUserInteractionEnabled:NO];
instead of
tableView.userInteractionEnabled = NO;
but it didn't work. How can I prevent swiping?
Edit:
Here is full code:
- (void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
__block UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
activityIndicator.center = cell.center;
activityIndicator.hidesWhenStopped = YES;
[self.tableView addSubview:activityIndicator];
[activityIndicator startAnimating];
tableView.userInteractionEnabled = NO;
RecentItem *item = (RecentItem *) [self.recentItems objectAtIndex:indexPath.row];
[dataController fetchAlbumWhichIncludesThisItem:item
success:^(VDAlbumCategory *albumCategory) {
NSInteger index = [albumCategory findIndexUsingNid:item.nid];
photos = [[NSArray alloc] initWithArray:albumCategory.photos];
PhotoPagesViewController *photoPagesViewController = [[PhotoPagesViewController alloc] initWithPhotos:photos];
NSDictionary* upperToolBarInfo = @{@"userPicturePath": item.userPicturePath,
@"realName": item.userName};
VDPhotoPagesFactory *factory = [[VDPhotoPagesFactory alloc] initWithUpperToolBarInfo:upperToolBarInfo];
EBPhotoPagesController *photoPagesController = [[EBPhotoPagesController alloc] initWithDataSource:photoPagesViewController delegate:photoPagesViewController photoPagesFactory: factory photoAtIndex:index];
[self presentViewController:photoPagesController animated:YES completion:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[activityIndicator removeFromSuperview];
tableView.userInteractionEnabled = YES;
});
}
}