真实设备中的动画比模拟器快得多

发布于 12-29 05:21 字数 446 浏览 3 评论 0原文

我正在制作按钮上图像变化的动画。我将时间设置为 0.6,模拟器中的动画效果与预期完全一致,但在 iPhone 4S 中,相同的动画在一眨眼的时间内发生,而不是 0.6 秒。

我已将动画持续时间更改为更短和更长,模拟器始终按预期工作,但真实设备始终超快,例如 0.1 秒或更快。

真实设备上的其他动画(例如更改视图控制器翻转过渡)都很好。

代码示例如下:

for (button in allButtons) {
    [UIView transitionWithView:button.view duration:0.6     
        ^{ [button setSelected:NO];
         }
}

allButtons 集合中有 80 个按钮。单独的按钮转换效果也很好。

为什么模拟器的工作方式与真实设备不同?

I'm animating the change of image on buttons. I have the time set to .6 which animates in the emulator exactly as expected but in iPhone 4S the same animation happens in a blink, not .6 seconds.

I've changed the animation duration to be shorter and longer, the emulator always works as expected but the real device is always super fast, like .1 second or faster.

Other animations on the real device like changing view controllers flip transition are fine.

Code sample like this:

for (button in allButtons) {
    [UIView transitionWithView:button.view duration:0.6     
        ^{ [button setSelected:NO];
         }
}

There are 80 buttons in the allButtons collection. Individual button transitions work fine as well.

Why does the emulator work differently than the real device?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

青衫负雪2025-01-05 05:21:45

你可以尝试:

    [UIView animateWithDuration:0.6
                 animations:^{ 
                     for (UIButton *button in allButtons) {
                         [button setSelected:NO];
                     }
                 }];

但这也不应该起作用(正如 Diwann 之前所说)。文档说明了什么是可动画的,并且“selected”属性不在该列表中,事实上它甚至不是 UIView 的属性,它是UIControl 只能为 UIView 的属性设置动画。

我刚刚在我的模拟器和 iOS 设备上尝试了你的伪代码(可以正常工作),但都没有动画。两个测试都将按钮设置为同时选择。

You could try:

    [UIView animateWithDuration:0.6
                 animations:^{ 
                     for (UIButton *button in allButtons) {
                         [button setSelected:NO];
                     }
                 }];

But this shouldn't work either (as Diwann said earlier.) The documentation states what is animatable and the "selected" property is not in that list, in fact its not even a property of UIView, it's a property of UIControl and you can only animate properties of UIView.

I just tried your pseudo code (made to work) on my simulator and iOS device and neither animated. Both tests set the buttons to selected all at once.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文