iphone – 为什么-animateWithDuration:delay:options:animations:completion:阻止UI?

iphone – 为什么-animateWithDuration:delay:options:animations:completion:阻止UI?,第1张

概述我一直认为Core Animation在后台执行动画.当我运行此代码时,我的UI交互将被阻止,直到动画结束: [UIView animateWithDuration:4.5 delay:0 options:options animations:^{ 我一直认为Core Animation在后台执行动画.当我运行此代码时,我的UI交互将被阻止,直到动画结束:

[UIVIEw animateWithDuration:4.5                       delay:0                     options:options                  animations:^{                    oldVIEw.Alpha = 0;                    newVIEw.Alpha = 1;                 }                   completion:^(BOol finished) {                    if (finished) {                        [oldVIEw removeFromSupervIEw];                    }                 }];

就像你可以看到持续时间很长,因此可以清楚地看到UI交互在动画时被阻止.

在动画开始时,UI交互开始被阻止,并且在动画结束时结束被阻止.

有没有办法同时启动UIVIEw动画,以便不阻止UI交互?

编辑澄清:我知道UI被阻止,因为我不能与屏幕上的任何控件交互为什么这个动画运行.那些其他控件与动画内容无关,并且不在视图层次结构中的同一分支上.此动画运行时,将阻止整个UI.当我将其设置为10秒时,UI会在动画运行时被阻止10秒.在iPhone 4上使用iOS 4.2进行测试.

解决方法 查看UIVIEw的文档,我在该方法的讨论部分中找到了这个:

During an animation,user interactions are temporarily Disabled for the vIEws being animated. (Prior to iOS 5,user interactions are Disabled for the entire application.) If you want users to be able to interact with the vIEws,include the UIVIEwAnimationoptionAllowUserInteraction constant in the options parameter.

因此,如果您希望继续允许用户交互,则必须在options参数中设置此常量.

总结

以上是内存溢出为你收集整理的iphone – 为什么-animateWithDuration:delay:options:animations:completion:阻止UI?全部内容,希望文章能够帮你解决iphone – 为什么-animateWithDuration:delay:options:animations:completion:阻止UI?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1084320.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存