【问题标题】:Animations are preventing touchesBegan动画正在阻止 touchesBegan
【发布时间】:2012-09-25 17:29:56
【问题描述】:

我有这个代码:

- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
    MainGame *newview = [[MainGame alloc] initWithNibName:@"MainGame" bundle:nil];
    newview.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
    [self presentModalViewController:newview animated:YES];
}

当我触摸屏幕时,它用于切换到一个名为 MainGame 的视图,但有时当我触摸屏幕时没有任何反应。

我想说的是,我的 touchesBegan 只是有时会收到触摸,其他时候会被忽略。

除了这段代码,我还运行了大约 1 - 4 个 UIView 动画,它们由以下人员设置:

[UIView animateWithDuration: ... ];

但是,如果我删除动画,它总是会识别 touchesBegan。

那么为什么我的动画会阻止 touchesBegan 被识别,我该如何阻止这种情况发生?

【问题讨论】:

    标签: ios cocoa-touch touchesbegan


    【解决方案1】:

    使用 UIView 方法:

    animateWithDuration:delay:options:animations:completion:
    

    并将选项设置为:

    UIViewAnimationOptionAllowUserInteraction
    

    这应该为你做。

    【讨论】:

    • 谢谢!现在工作正常。当 Stackoverflow 允许我时,我会将您的答案标记为正确。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    • 2017-07-05
    相关资源
    最近更新 更多