I have a uitableview that implements a popover ( PopoverView ) when a cell is being listened, and then the popover is rejected on any other click on the screen. The problem is that if the user briefly clicks or clicks on a cell twice, this will cause several instances of popoverviews to appear, and then the application will work. I'm looking for a way to disable double-clicking on a cell and / or UITableView in general OR is there a way to defer touches on UITableViewCell any ideas?
I already tried this one , but in my case it does not work. Another approach would be to check if a PopoverView is present, if so, and then not allow the creation of another instance. I tried this and this , and both of them do not work in my case.
Here is my code where I call popover view on didSelectRowAtIndexpath :
- (void)tableView:(UITableView *)TableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [TableView cellForRowAtIndexPath:indexPath]; sti = [[SelectedTeamsInfo alloc] init]; MyLeagueStandings *info = [fetchedResultsController objectAtIndexPath:indexPath]; [sti getAllScheduleForTeam:info.urlforteam]; NSString *title = info.teamname;
Decision
In the interface class:
BOOL PopoverYN;
In the implementation class:
- (void)tableView:(UITableView *)TableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // If the popover is not available then display it else do nothing since one is already displayed. if (PopoverYN == NO) { PopoverYN = YES; UITableViewCell *cell = [TableView cellForRowAtIndexPath:indexPath]; sti = [[SelectedTeamsInfo alloc] init]; MyLeagueStandings *info = [fetchedResultsController objectAtIndexPath:indexPath]; [sti getAllScheduleForTeam:info.urlforteam]; NSString *title = info.teamname; // If title length is greater then 32 truncate it to fit. if (title.length > 32) { title = [info.teamname substringToIndex:29]; title = [title stringByAppendingString:@"..."]; } [PopoverView showPopoverAtPoint:cell.center inView:self.view withTitle:title withContentView:sti.view delegate:self]; } }
source share