EXC_BAD_ACCESS 当 popViewControllerAnimated 在基于导航的应用程序中时

发布于 2024-10-06 16:39:41 字数 1234 浏览 4 评论 0原文

我不明白为什么在弹出回到导航堆栈中的上一个视图控制器时会崩溃。 问题是我正在使用自定义导航栏(原始导航栏被隐藏,我的自定义按钮触发导航 - 推送和弹出 - 相反)。

跟踪我得到:

Program received signal:  “EXC_BAD_ACCESS”.

#0  0x011a4a60 in objc_msgSend
#1  0x0044e37c in -[UIImageView(UIImageViewInternal) _canDrawContent]
#2  0x003bf3df in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#3  0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#4  0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#5  0x003bdfc4 in -[UIView(Hierarchy) _postMovedFromSuperview:]
#6  0x003b6dfc in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#7  0x003b514f in -[UIView(Hierarchy) addSubview:]
#8  0x005ca471 in -[UINavigationTransitionView transition:fromView:toView:]
#9  0x005c9ed5 in -[UINavigationTransitionView transition:toView:]
#10 0x0043c606 in -[UINavigationController _startDeferredTransitionIfNeeded]
#11 0x0043c292 in -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:]
#12 0x0043bfa9 in -[UINavigationController popViewControllerWithTransition:]
#13 0x0043f62b in -[UINavigationController popToViewController:transition:]
#14 0x000124fa in -[BaseViewController bottomNavigationFiredController:] at BaseViewController.m:187

I can't figure out why I get crash when poping back to previous view contoller in navigation stack.
The thing is I am using custom navigation bar (original is hidded and my custom buttons fires navigation - push and pop - instead).

Trace I get:

Program received signal:  “EXC_BAD_ACCESS”.

#0  0x011a4a60 in objc_msgSend
#1  0x0044e37c in -[UIImageView(UIImageViewInternal) _canDrawContent]
#2  0x003bf3df in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#3  0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#4  0x003bf1b0 in -[UIView(Internal) _didMoveFromWindow:toWindow:]
#5  0x003bdfc4 in -[UIView(Hierarchy) _postMovedFromSuperview:]
#6  0x003b6dfc in -[UIView(Internal) _addSubview:positioned:relativeTo:]
#7  0x003b514f in -[UIView(Hierarchy) addSubview:]
#8  0x005ca471 in -[UINavigationTransitionView transition:fromView:toView:]
#9  0x005c9ed5 in -[UINavigationTransitionView transition:toView:]
#10 0x0043c606 in -[UINavigationController _startDeferredTransitionIfNeeded]
#11 0x0043c292 in -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:]
#12 0x0043bfa9 in -[UINavigationController popViewControllerWithTransition:]
#13 0x0043f62b in -[UINavigationController popToViewController:transition:]
#14 0x000124fa in -[BaseViewController bottomNavigationFiredController:] at BaseViewController.m:187

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

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

发布评论

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

评论(2

她比我温柔 2024-10-13 16:39:41

我遇到了同样的问题,可能是因为您的最后一个视图不再保留。最好的方法可能是尝试通过创建属性并综合它来保留您之前的视图。

然后尝试使用

[self.navigationConroller popViewControllerAnimated:YES];

或 弹出到所需视图

[self.navigationController popToViewController:myview animated:YES];

或弹出到根视图

[self.navigationController popToRootViewControllerAnimated:YES];

让我知道它是否对您有帮助。因为当您尝试转到已发布的视图时会出现此错误。

I had faced the same problem that could be because your last view is no longer retained.The best way could be try to retain your previous view by making the property and synthesizing it.

Then try to use

[self.navigationConroller popViewControllerAnimated:YES];

or to pop to desired view

[self.navigationController popToViewController:myview animated:YES];

or to pop to rootview

[self.navigationController popToRootViewControllerAnimated:YES];

Let me know if it helps you.Because this error comes when you are attempting to go to a view which has been already released.

蛮可爱 2024-10-13 16:39:41

值得记住的是,当视图控制器在导航堆栈中被推开时(新的视图控制器被推入),即使它本身没有被释放(保留了导航控制器堆栈),它的主视图也会被释放(与当然,所有这些都是子视图)。

因此,这种类型的崩溃主要指向内存管理的 UI 部分(很可能是自动释放的 UIImages 的双重释放,这就是我的情况;-)。

希望它可以帮助人们理解 UINavigationController 如何管理内存。

It is worth remembering that when viewcontroller is pushed away in navigation stack (new view controler is push in), even if it is not being released itself (retained it the navigation controller stack), its maim view is being released (with all of it's subviews of course) thou.

So this type of crash will mostly point to UI part of memory management (most problably double release of autoreleased UIImages which was my case;-).

Hope it helps someone to understand how UINavigationController manages memory.

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