问题是用户可以在一个时刻点击两个执行push
segue的按钮,在这种情况下,两个视图控制器被一个接一个地推动。这是一段代码:
- (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执行转换时禁用屏幕上的触摸。
答案 0 :(得分:0)
UIApplication
为您提供beginIgnoringInteractionEvents
和endIgnoringInteractionEvents
,因此您可以在特定时间禁用所有触摸事件处理(例如视图转换)。
每次拨打endIgnoringInteractionEvents
时,请务必致电beginIgnoringInteractionEvents
。
答案 1 :(得分:0)
为什么不设置self.view.userInteractionEnabled = NO;
或tableView的superView。这将取消您在任何superView的子视图中发生的所有触摸。