+[CATransaction Synchronize] 在事务中调用

发布于 2024-12-01 05:36:40 字数 469 浏览 3 评论 0原文

如果我在从服务加载数据时关闭 iPad 应用程序,该应用程序会关闭,但随后会立即再次打开,而无需我执行任何操作。此时此刻,我什么也做不了;我无法关闭应用程序,也无法与应用程序或设备交互。再次使用该设备的唯一方法是重新启动它。该应用程序不会崩溃,它只是禁用设备。

发生这种情况时,在applicationWillResignActiveapplicationDidEnterBackground之后,控制台中会出现以下行三次:

+[CATransaction synchronize] called within transaction

如果应用程序崩溃,那几乎没问题,但事实上,设备变得完全无用是一个大问题。如果我能够拦截此错误或以某种方式检测 CATransaction 何时引发此问题,那就没问题了。

有什么想法吗?

If I close my iPad app while I'm loading data from services, the app closes but then immediately opens again without my doing anything. At this point, I am not able to do anything; I can't close the app and I can't interact with the app or the device. The only way to use the device again is to restart it. The app does not crash, it simply disables the device.

When this happens, the following line appears in the console three times right after applicationWillResignActive and applicationDidEnterBackground:

+[CATransaction synchronize] called within transaction

It'd be almost okay if the app crashes, but the fact that the device is rendered completely useless is a huge problem. If I could intercept this bug or somehow detect when CATransaction raises this issue, then that'd be fine.

Any ideas?

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

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

发布评论

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

评论(2

柏林苍穹下 2024-12-08 05:36:40

当主线程上发生多个动画时,就会发生这种情况。我遇到了同样的问题。在我的例子中,应用程序在 CALayer 动画和旋转设备的同时冻结。所以我在旋转设备时停止了动画。

查找代码

[CATransaction begin]

//foo
[CATransaction commit]

确保此代码中的动画不会与主线程上的其他动画重叠。

This happens when more than one animations are taking place on main thread. I faced the same problem. In my case application freezes while animating the CALayer and rotating the device simultaneously. So I stopped the animation while rotating the device.

Look for the code

[CATransaction begin]

//foo
[CATransaction commit]

Make sure that animation inside this code does not overlap with your other animations on main thread.

铃予 2024-12-08 05:36:40

如果您使用 UIWindow.rootViewController 完全跳过故事板,这可能会显示在日志中。

要放弃日志消息,您可以删除 Storyboard,删除 info.plist 中将 Storyboard 与您的应用关联的键,将 LaunchScreen.storyboard 设置为目标中的 Main Interface并使用

window = UIApplication.shared.keyWindow!

内部AppDelegate来获取主窗口并在其上分配您的UIViewController

This can show up in the logs if you use UIWindow.rootViewController to skip storyboards altogether.

To ditch the log message you can remove the storyboard, remove the key associating the Storyboard with your app in info.plist, set LaunchScreen.storyboard as the Main Interface in the target and use

window = UIApplication.shared.keyWindow!

inside AppDelegate to get the main window and assign your UIViewController on it.

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