Frage

I have a tableview A whose row entries custom segue to a GridView B (actually using the open source MMGridView). The subview cells of the gridView/scrollView use touchesBegan/TouchesEnd to detect their selection.

I am using the storyboard, and the custom segues are animated and initiated by didselectrowatindexpath/performsegue in the tableView.

The problem is that once a tableview row has been selected, additional taps are being queued up and passed on to the individual gridCells.

In the custom segue, I have tried setting destinationviewcontroller.view.userInteractionEnabled = NO; And then re-enabling it in the destinationViewController's viewDidAppear. This did not work, and the queued up touch events were still passed on to the gridView's subcells.

How do I flush or cancel any touch events that seemed to have queued up during a custom-animated transition?

EDIT: Removing the custom segue seemed to stop the "queued up" touch event behavior. Or maybe the segue now simply occurs quickly enough so that no touch events are happening during it? For completeness sake, here is my custom uistoryboardsegue that is giving me problems:

#import "QuartzCore/QuartzCore.h"

@implementation TTOCustomSegue

-(void)perform {

UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
UIViewController *destinationController = (UIViewController*)[self destinationViewController];
//destinationController.view.userInteractionEnabled = NO;

CATransition* transition = [CATransition animation];
transition.duration = .4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
transition.type = kCATransitionFade; 
transition.subtype = nil;

[sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];    
[sourceViewController.navigationController pushViewController:destinationController animated:NO];       
}
@end
War es hilfreich?

Lösung

There shouldn't be any queued up events. Make sure you are not blocking the main thread somehow.

To completely block event handling during animations, there are some useful method on UIApplication.

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];

[[UIApplication sharedApplication] endIgnoringInteractionEvents];

These methods are very useful if you need to start the animation with a delay and you don't want any user actions during the delay phase.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top