我真的无法弄清楚这一点。当我点击链接从我的应用程序中打开Safari时,浏览网页,然后返回到我的应用程序,我可以打开并浏览tabBarItems
中的两个UITabBar
。但是,当我尝试选择一个atIndex: 0
时,我得到一个EXEC_BAD_ACCESS
以及以下内容:(。任何人都可以帮我弄清楚如何使这不发生吗?我目前没有任何代码在will
或didEnterBackground
或Foreground
中执行。无。所以问题必须在第一个标签的UIViewController
中。(哦,我不知道为什么会这样添加子视图。相关?)。想法?
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`
答案 0 :(得分:2)
BAD_ACCESS意味着您可能正在访问指向已释放内存的内容。在您描述的情况下,由于内存警告较低,您的视图很可能会被卸载 - 尤其是那些不可见的警告。如果你没有为这次卸载做好准备,当视图重新加载时,通常会发生不好的事情。确保在视图控制器中正确处理viewDidUnload方法和倒数viewDidLoad。