切换到选项卡时应用程序崩溃
app crashes when switching to tab
我有一个带有两个选项卡的选项卡栏控制器,通常我可以在选项卡之间正常移动,但有一点我 select 第二个选项卡和应用程序在 te 日志中崩溃它只显示 lldb如果我写 bt
它会给我以下内容
* thread #1: tid = 0x5dc59, 0x0061b0b2 libobjc.A.dylib`objc_msgSend + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1000000c)
frame #0: 0x0061b0b2 libobjc.A.dylib`objc_msgSend + 14
frame #1: 0x0134e10c UIKit`-[UITabBarController _tabBarItemClicked:] + 102
frame #2: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #3: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #4: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #5: 0x014f66fd UIKit`-[UITabBar _sendAction:withEvent:] + 466
frame #6: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #7: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #8: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #9: 0x012dc13a UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #10: 0x012dc557 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #11: 0x012dc172 UIKit`-[UIControl sendActionsForControlEvents:] + 48
frame #12: 0x014fb690 UIKit`-[UITabBar(Static) _buttonUp:] + 123
frame #13: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #14: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #15: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #16: 0x012dc13a UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #17: 0x012dc557 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #18: 0x012db7c1 UIKit`-[UIControl touchesEnded:withEvent:] + 660
frame #19: 0x011f3caa UIKit`-[UIWindow _sendTouchesForEvent:] + 874
frame #20: 0x011f4786 UIKit`-[UIWindow sendEvent:] + 792
frame #21: 0x011b2681 UIKit`-[UIApplication sendEvent:] + 242
frame #22: 0x011c2ab8 UIKit`_UIApplicationHandleEventFromQueueEvent + 21484
frame #23: 0x011962e7 UIKit`_UIApplicationHandleEventQueue + 2300
frame #24: 0x008a006f CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #25: 0x00895b7d CoreFoundation`__CFRunLoopDoSources0 + 253
frame #26: 0x008950d8 CoreFoundation`__CFRunLoopRun + 952
frame #27: 0x00894a5b CoreFoundation`CFRunLoopRunSpecific + 443
frame #28: 0x0089488b CoreFoundation`CFRunLoopRunInMode + 123
frame #29: 0x04bab2c9 GraphicsServices`GSEventRunModal + 192
frame #30: 0x04bab106 GraphicsServices`GSEventRun + 104
frame #31: 0x0119a0b6 UIKit`UIApplicationMain + 1526
* frame #32: 0x00072624 PIBA`main + 180 at AppDelegate.swift:12
frame #33: 0x03526ac9 libdyld.dylib`start + 1
据我了解,从选项卡切换时确实会崩溃,但为什么?
我启用了 NS Zombies 并打印了
*** -[PIBA.PreguntasViewController respondsToSelector:]: message sent to deallocated instance 0x7ae2dea0
现在没有关于切换选项卡的问题,但是这个已释放的实例意味着您尝试访问的某些实例现在不在舞台(内存)上或已从内存地址中删除。所以你绝对不能访问任何不存在的东西在那里你正在寻找希望你明白如果你有任何困惑问我
我也遇到过类似的情况。在我的例子中,这条消息是由于数组堆栈溢出而出现的。此解决方案帮助我调试错误:
- 确保您没有选中此选项 "Debug->Debug Workflow->Always Show Disassembly"
- 并允许:产品->方案->编辑方案,运行->诊断-> 地址消毒器。
之后它会在您的代码中显示溢出,您将能够修复它。
P.S.: 但是我也很疑惑,为什么只有在tab切换的时候才会出现应用逻辑错误...
我有一个带有两个选项卡的选项卡栏控制器,通常我可以在选项卡之间正常移动,但有一点我 select 第二个选项卡和应用程序在 te 日志中崩溃它只显示 lldb如果我写 bt
它会给我以下内容
* thread #1: tid = 0x5dc59, 0x0061b0b2 libobjc.A.dylib`objc_msgSend + 14, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x1000000c)
frame #0: 0x0061b0b2 libobjc.A.dylib`objc_msgSend + 14
frame #1: 0x0134e10c UIKit`-[UITabBarController _tabBarItemClicked:] + 102
frame #2: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #3: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #4: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #5: 0x014f66fd UIKit`-[UITabBar _sendAction:withEvent:] + 466
frame #6: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #7: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #8: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #9: 0x012dc13a UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #10: 0x012dc557 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #11: 0x012dc172 UIKit`-[UIControl sendActionsForControlEvents:] + 48
frame #12: 0x014fb690 UIKit`-[UITabBar(Static) _buttonUp:] + 123
frame #13: 0x0061d7cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #14: 0x0119ba40 UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #15: 0x0119b9d2 UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #16: 0x012dc13a UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #17: 0x012dc557 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #18: 0x012db7c1 UIKit`-[UIControl touchesEnded:withEvent:] + 660
frame #19: 0x011f3caa UIKit`-[UIWindow _sendTouchesForEvent:] + 874
frame #20: 0x011f4786 UIKit`-[UIWindow sendEvent:] + 792
frame #21: 0x011b2681 UIKit`-[UIApplication sendEvent:] + 242
frame #22: 0x011c2ab8 UIKit`_UIApplicationHandleEventFromQueueEvent + 21484
frame #23: 0x011962e7 UIKit`_UIApplicationHandleEventQueue + 2300
frame #24: 0x008a006f CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #25: 0x00895b7d CoreFoundation`__CFRunLoopDoSources0 + 253
frame #26: 0x008950d8 CoreFoundation`__CFRunLoopRun + 952
frame #27: 0x00894a5b CoreFoundation`CFRunLoopRunSpecific + 443
frame #28: 0x0089488b CoreFoundation`CFRunLoopRunInMode + 123
frame #29: 0x04bab2c9 GraphicsServices`GSEventRunModal + 192
frame #30: 0x04bab106 GraphicsServices`GSEventRun + 104
frame #31: 0x0119a0b6 UIKit`UIApplicationMain + 1526
* frame #32: 0x00072624 PIBA`main + 180 at AppDelegate.swift:12
frame #33: 0x03526ac9 libdyld.dylib`start + 1
据我了解,从选项卡切换时确实会崩溃,但为什么?
我启用了 NS Zombies 并打印了
*** -[PIBA.PreguntasViewController respondsToSelector:]: message sent to deallocated instance 0x7ae2dea0
现在没有关于切换选项卡的问题,但是这个已释放的实例意味着您尝试访问的某些实例现在不在舞台(内存)上或已从内存地址中删除。所以你绝对不能访问任何不存在的东西在那里你正在寻找希望你明白如果你有任何困惑问我
我也遇到过类似的情况。在我的例子中,这条消息是由于数组堆栈溢出而出现的。此解决方案帮助我调试错误:
- 确保您没有选中此选项 "Debug->Debug Workflow->Always Show Disassembly"
- 并允许:产品->方案->编辑方案,运行->诊断-> 地址消毒器。
之后它会在您的代码中显示溢出,您将能够修复它。
P.S.: 但是我也很疑惑,为什么只有在tab切换的时候才会出现应用逻辑错误...