dea*_*ter 11 iphone animation objective-c user-interaction ios
在我的应用程序中,我有一些动画.例如,我在主菜单中有一个按钮,当你点击它时动画开始(比如移动一些地方等),在动画结束时它会导航到另一个页面.我需要的是在动画期间禁用用户交互.因为在动画期间如果我按下按钮的起点,应该导航的页面打开两次.总而言之,如果我在动画过程中不让任何用户交互,我的问题就会得到解决.我怎样才能做到这一点?
swe*_*bal 20
动画前:
self.view.userInteractionEnabled = NO;
Run Code Online (Sandbox Code Playgroud)
并在动画完成块中:
self.view.userInteractionEnabled = YES;
Run Code Online (Sandbox Code Playgroud)
Man*_*esh 18
这可能有所帮助:
// for ignoring event
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
Run Code Online (Sandbox Code Playgroud)
代码如下:
[UIView animateWithDuration:1.0 animations:^{
//some animation
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
}
completion:^(BOOL done){
if (done){
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
}
}
];
Run Code Online (Sandbox Code Playgroud)
很简单,你可以设置setUserInteractionEnabled到NO动画开始之前,以及在动画完成处理程序设置回YES.
[myObject setUserInteractionEnabled:NO];
[UIView animateWithDuration:1.0 animations:^{
[myObject setTransform:CGAffineTransformMakeTranslation(100, 100)];//some animation
}completion:^(BOOL done){
if (done){
[myObject setUserInteractionEnabled:YES];
}
}];
Run Code Online (Sandbox Code Playgroud)
小智 5
你不必破解完成块 - 有一个动画选项可以完全做到这一点:
[UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction
animations:^{
// animations here
}
completion:nil];
Run Code Online (Sandbox Code Playgroud)
如果您已设置UIViewAnimationOptionAllowUserInteraction,则允许用户交互.
| 归档时间: |
|
| 查看次数: |
8763 次 |
| 最近记录: |