My iPhone app crashes after opening it from background and selecting Tab atIndex:0

穿精又带淫゛_ 提交于 2019-12-23 05:32:08

问题


I really can't figure this out. When I click a link to open Safari from within my app, browse through the webpage, then return to my app, I can open and browse two tabBarItems in my UITabBar. But, when I try to select the one atIndex: 0, I get an EXEC_BAD_ACCESS and the following :(. Can anyone help me figure out how to make this not happen? I currently don't have any code that executes in will or didEnterBackground or Foreground. None. So the problem must be in the UIViewController for the first tab. (Oh and I don't know why it's adding a subview. Related?). Thoughts?

Thread 0 Crashed:  Dispatch queue: com.apple.main-thread
        0   libobjc.A.dylib                 0x0109ba63 objc_msgSend + 23
        1   UIKit                           0x0031f3df -[UIView(Internal) _didMoveFromWindow:toWindow:] + 966
        2   UIKit                           0x0031f1b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407
        3   UIKit                           0x0031f1b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407
        4   UIKit                           0x0031f1b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407
        5   UIKit                           0x0031f1b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407
        6   UIKit                           0x0031f1b0 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 407
        7   UIKit                           0x0031dfc4 -[UIView(Hierarchy) _postMovedFromSuperview:] + 166
        8   UIKit                           0x00316dfc -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1080
        9   UIKit                           0x0031514f -[UIView(Hierarchy) addSubview:] + 57
        10  UIKit                           0x003725ac -[UITransitionView transition:fromView:toView:] + 563
        11  UIKit                           0x00371955 -[UITransitionView transition:toView:] + 129
        12  UIKit                           0x003a6383 -[UITabBarController transitionFromViewController:toViewController:transition:shouldSetSelected:] + 459
        13  UIKit                           0x003a4d86 -[UITabBarController transitionFromViewController:toViewController:] + 64
        14  UIKit                           0x003a6b7e -[UITabBarController _setSelectedViewController:] + 263
        15  UIKit                           0x003a69ed -[UITabBarController _tabBarItemClicked:] + 352`

回答1:


The BAD_ACCESS means you are likely accessing something that points to memory that has been released. In the situation you describe, it's very possible that your views are unloading due to a low memory warning - particularly ones that aren't visible. If you aren't prepared for this unloading, when the view reloads, bad things usually happen. Make sure you are appropriately handling your viewDidUnload method and the reciprocal viewDidLoad in your view controllers.



来源:https://stackoverflow.com/questions/4870217/my-iphone-app-crashes-after-opening-it-from-background-and-selecting-tab-atindex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!