切换到标签

时间:2015-09-05 21:15:56

标签: ios swift uitabbarcontroller

我有一个带有两个标签的标签栏控制器,通常我可以在标签之间正常移动,但有一点我选择第二个标签,应用程序在te日志中崩溃它只显示lldb如果我写{{1它给了我以下

bt

从我可以理解的是,当从tab切换时它确实崩溃但是为什么?

我启用了NS Zombies并打印了

* 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

2 个答案:

答案 0 :(得分:1)

现在没有关于切换选项卡的问题,但是这个解除分配的实例意味着你正试图访问的一些实例现在不在舞台(内存)上或从内存地址中删除。所以你绝对不能访问那里没有的任何东西,如果你有任何困惑,我希望你能理解我的希望

答案 1 :(得分:1)

我有类似的情况。在我的情况下,由于数组堆栈溢出,此消息已存在。这个解决方案帮助我调试错误:

  1. 确保您拥有此选项" Debug-> Debug Workflow-> Always Show Disassembly"没检查
  2. 并允许:产品 - >方案 - >编辑方案,运行 - >诊断 - >地址Sanitizer。
  3. 之后它将在您的代码中显示溢出,您将能够解决这个问题。

    P.S。:但我也很困惑,为什么应用程序逻辑中的错误仅在选项卡切换时出现...

相关问题