我的 iPhone 应用程序从后台打开并选择 Tab atIndex:0 后崩溃

发布于 2024-10-16 00:28:41 字数 2247 浏览 8 评论 0原文

我实在想不通这个问题。当我单击链接从应用程序中打开 Safari、浏览网页,然后返回到我的应用程序时,我可以在 UITabBar 中打开并浏览两个 tabBarItems。但是,当我尝试选择一个 atIndex: 0 时,我得到一个 EXEC_BAD_ACCESS 和以下内容:(。任何人都可以帮我弄清楚如何避免这种情况发生吗?我目前没有在 willdidEnterBackgroundForeground None 中执行的任何代码,因此问题一定出在 中。 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`

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`

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诗酒趁年少 2024-10-23 00:28:41

BAD_ACCESS 意味着您可能正在访问指向已释放内存的内容。在您描述的情况下,您的视图很可能由于内存不足警告而被卸载 - 特别是那些不可见的视图。如果您没有为此卸载做好准备,那么当视图重新加载时,通常会发生不好的事情。确保您在视图控制器中正确处理 viewDidUnload 方法和倒数 viewDidLoad 。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文