gpt4 book ai didi

ios - SCNCamera 旋转时应用程序在“后退”按钮上崩溃

转载 作者:行者123 更新时间:2023-12-01 23:20:41 26 4
gpt4 key购买 nike

没有找到问题或答案,所以我自己发布。当我为 SCNView 启用允许相机控制,然后滑动以使相机开始旋转,然后按导航栏中的“后退”按钮时,我的应用程序崩溃了。崩溃堆栈跟踪:

* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x18)
frame #0: 0x0000000113e3d94b libobjc.A.dylib`objc_msgSend + 11
frame #1: 0x00000001158a2eb6 SceneKit`__42-[SCNCameraController _setInertiaRunning:]_block_invoke.166 + 31
frame #2: 0x00000001173e33f7 libdispatch.dylib`_dispatch_call_block_and_release + 12
frame #3: 0x00000001173e443c libdispatch.dylib`_dispatch_client_callout + 8
frame #4: 0x00000001173ef6f0 libdispatch.dylib`_dispatch_main_queue_callback_4CF + 628
frame #5: 0x00000001149bbee9 CoreFoundation`__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
frame #6: 0x0000000114980592 CoreFoundation`__CFRunLoopRun + 2402
frame #7: 0x000000011497f9b9 CoreFoundation`CFRunLoopRunSpecific + 409
frame #8: 0x00000001199a29c6 GraphicsServices`GSEventRunModal + 62
frame #9: 0x000000011029b5e8 UIKit`UIApplicationMain + 159
* frame #10: 0x000000010e6f73e7 ShowIt`main at AppDelegate.swift:13
frame #11: 0x0000000117460d81 libdyld.dylib`start + 1
frame #12: 0x0000000117460d81 libdyld.dylib`start + 1

因此,发送到已释放相机的消息和应用程序崩溃。

最佳答案

找到了这个解决方案:

override func viewDidDisappear(_ animated: Bool) {
super.viewDidDisappear(animated)

if isMovingFromParentViewController {
// Prevent crash on back tap when camera rotates
scnView.pointOfView = nil
}
}

基本上只需在 Controller 弹出时将相机节点设置为nil即可。

关于ios - SCNCamera 旋转时应用程序在“后退”按钮上崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47315253/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com