Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS:在调用';准备问卷:';_Ios_Touch_Transition_Uistoryboardsegue - Fatal编程技术网

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:
方法中使用自定义的基于时间的标志解决了这个问题。我有一个复杂的用户界面,这个代码不容易插入。