iOS:在调用';准备问卷:';
问题是,用户可以点击两个按钮,在一瞬间执行iOS:在调用';准备问卷:';,ios,touch,transition,uistoryboardsegue,Ios,Touch,Transition,Uistoryboardsegue,问题是,用户可以点击两个按钮,在一瞬间执行pushsegues,在这种情况下,两个视图控制器会依次按下。下面是一段代码: - (void)cellTapped:(MyCell *)cell { NSLog(@"cell tapped %p", cell); [self performSegueWithIdentifier:@"MySegue" sender:cell]; } ... -(void)prepareForSegue:(UIStoryboardSegue *)segue
push
segues,在这种情况下,两个视图控制器会依次按下。下面是一段代码:
- (void)cellTapped:(MyCell *)cell
{
NSLog(@"cell tapped %p", cell);
[self performSegueWithIdentifier:@"MySegue" sender:cell];
}
...
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"prepareForSegue: %@", [segue identifier]);
}
当我立即点击两个按钮时,控制台日志:
2014-05-22 18:33:09:622 zzz[1737:1547] cell tapped 0x17558e10
2014-05-22 18:33:09:631 zzz[1737:1547] prepareForSegue: MySegue
2014-05-22 18:33:09:873 zzz[1737:1547] cell tapped 0x17554720
2014-05-22 18:33:09:875 zzz[1737:1547] prepareForSegue: MySegue
看来这是一只虫子。我想在segue执行转换时禁用屏幕上的触摸功能。
UIApplication
为您提供了beginIgnoringInteractionEvents
和endIgnoringInteractionEvents
,因此您可以在特定时间内禁用所有触摸事件处理(如视图转换)
确保每次调用
beginIgnoringInteractionEvents
时调用endIgnoringInteractionEvents
一次,为什么不直接设置self.view.userInteractionEnabled=NO代码>或tableView的superView。这将取消在superView的任何子视图中发生的所有触摸。最好控制所有触摸。我必须注意,它不能解决我的问题(如果我在prepareforsgue:
中调用beginIgnoringInteractionEvents
)。看起来触摸是用延迟机制处理的。所以我在celltrapped:
方法中使用自定义的基于时间的标志解决了这个问题。我有一个复杂的用户界面,这个代码不容易插入。