Custom Segue期间排队的触摸事件



我有一个表视图a,它的行条目自定义为GridView B(实际上是使用开源MMGridView)。gridView/sollView的子视图单元格使用touchesBegan/TouchesEnd来检测其选择。

我使用的是情节串连板,自定义片段由didselecrowatindexpath/performsegue在tableView中设置动画并启动。

问题是,一旦选择了表视图行,就会有额外的抽头排队并传递给各个网格单元。

在自定义段中,我尝试设置destinationviewcontroller.view.userInteractionEnabled=NO;然后在destinationViewController的视图中重新启用它。这不起作用,排队的触摸事件仍然传递到gridView的子单元。

如何刷新或取消在自定义动画转换过程中排队的任何触摸事件?

编辑:删除自定义分段似乎可以停止"排队"的触摸事件行为。或者,segue现在只是发生得足够快,以至于在它的过程中没有发生触摸事件?为了完整起见,这里是我的自定义用户板,它给我带来了问题:

#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

不应该有任何排队的事件。确保你没有以某种方式阻塞主线程。

为了完全阻止动画过程中的事件处理,UIApplication上有一些有用的方法。

[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];

如果需要延迟启动动画,并且不希望在延迟阶段执行任何用户操作,则这些方法非常有用。

最新更新