我有一個tableview A的行條目自定義繼承到一個GridView B(實際上使用開源MMGridView)。 gridView/scrollView的子視圖單元格使用touchesBegan/TouchesEnd來檢測它們的選擇。觸摸事件在自定義塞格期間排隊?
我正在使用故事板,並且自定義段落由tableView中的didselectrowatindexpath/performsegue動畫和啓動。
問題是,一旦選擇了tableview行,其他的水龍頭正在排隊並傳遞到單個gridCells。
在自定義的segue中,我試過設置destinationviewcontroller.view.userInteractionEnabled = NO;然後在destinationViewController的viewDidAppear中重新啓用它。這不起作用,排隊的觸摸事件仍然傳遞給gridView的子單元。
如何在自定義動畫過渡期間刷新或取消似乎已經排隊的任何觸摸事件?
編輯:刪除自定義segue似乎停止「排隊」觸摸事件的行爲。或者,也許現在的賽格發生的速度足夠快,以免在賽事中發生觸摸事件?爲了完整起見,這裏是我的習慣uistoryboardsegue,給我的問題:
#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
看上去發生的事情是,即使動畫未完成,目標視圖控制器仍在運行並踢踢和接收觸摸事件。啊。爲了在轉換/動畫期間真正地禁止用戶交互,看起來我需要使用不同的轉換方法,例如, animateWithDuration有一個完成塊,我可以重新啓用用戶交互,或者一個允許設置UIViewAnimationOptionAllowUserInteraction的動畫方法。不幸的是,改變segues的動畫方法是另一種蠕蟲。 –