弹出视图控制器时崩溃

时间:2013-08-23 05:48:41

标签: ios objective-c uinavigationcontroller

从表格视图中选择项目后,当我在委托回调中调用[self.navigationController popViewControllerAnimated:YES];时,我看到一个奇怪的崩溃。在Xcode中没有跟踪打印到控制台 - 但这是系统控制台中可用的堆栈 - 任何想法?

Thread 0:: Dispatch queue: com.apple.main-thread
0   libsystem_kernel.dylib          0x94f5e332 __kill + 10
1   libsystem_kernel.dylib          0x94f5d932 kill$UNIX2003 + 32
2   CoreFoundation                  0x01c9876b CFHash + 43
3   CoreFoundation                  0x01c8f8b4 __CFDictionaryStandardHashKey + 36
4   CoreFoundation                  0x01cbce9c CFBasicHashRemoveValue + 1148
5   CoreFoundation                  0x01cca669 CFDictionaryRemoveValue + 185
6   Foundation                      0x011a3162 -[NSISEngine setIntegralizationAdjustment:forMarker:] + 50
7   Foundation                      0x011a97ec -[NSISEngine removeConstraintWithMarker:] + 651
8   Foundation                      0x011b388e -[NSLayoutConstraint _removeFromEngine:] + 277
9   UIKit                           0x00a80d36 -[UIView(UIConstraintBasedLayout) _layoutEngine_willRemoveLayoutConstraint:] + 64
10  UIKit                           0x005ac2ae __48-[UIScrollView _setAutomaticContentConstraints:]_block_invoke_0 + 181
11  Foundation                      0x011a8733 -[NSISEngine withAutomaticOptimizationDisabled:] + 57
12  UIKit                           0x00a80a5c -[UIView(UIConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] + 63
13  UIKit                           0x005ac1bb -[UIScrollView _setAutomaticContentConstraints:] + 122
14  UIKit                           0x005ac9ca -[UIScrollView _rememberDependentConstraint:] + 123
15  UIKit                           0x00a8ce60 ___updateViewDependenciesForConstraint_block_invoke_0 + 51
16  UIKit                           0x00a80cee _updateViewDependenciesForConstraint + 224
17  UIKit                           0x00a80bea -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 202
18  UIKit                           0x00a80da7 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 61
19  UIKit                           0x00594be4 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 447
20  UIKit                           0x005a081f -[UIScrollView _didMoveFromWindow:toWindow:] + 65
21  UIKit                           0x0059505d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1592
22  UIKit                           0x0059505d -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1592
23  UIKit                           0x005905e6 -[UIView(Hierarchy) _postMovedFromSuperview:] + 157
24  UIKit                           0x00596af4 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1784
25  UIKit                           0x0058eeed -[UIView(Hierarchy) addSubview:] + 56
26  UIKit                           0x007c58a9 -[UINavigationTransitionView transition:fromView:toView:] + 513
27  UIKit                           0x007c56a0 -[UINavigationTransitionView transition:toView:] + 55
28  UIKit                           0x00641c61 -[UINavigationController _startTransition:fromViewController:toViewController:] + 2344
29  UIKit                           0x00641eab -[UINavigationController _startDeferredTransitionIfNeeded:] + 386
30  UIKit                           0x006433d6 _popViewControllerNormal + 280
31  UIKit                           0x00643675 -[UINavigationController _popViewControllerWithTransition:allowPoppingLast:] + 449
32  UIKit                           0x0c53b780 -[UINavigationControllerAccessibility(SafeCategory) _popViewControllerWithTransition:allowPoppingLast:] + 143
33  UIKit                           0x00642625 -[UINavigationController popViewControllerAnimated:] + 57

更新

我很确定这是一个内部自动布局问题,就像这里发布的一样: Strange Crash when dismissing view controller, auto-layout to blame?

我想我会切换回支柱和弹簧......

4 个答案:

答案 0 :(得分:4)

你试图通过站立来切割树枝:)

如果要弹出当前显示在屏幕上的视图控制器。你可以这样做:

[self.navigationController popViewControllerAnimated:YES];

答案 1 :(得分:2)

你在哪里调用了委托,之后就可以调用

[self.navigationController popViewControllerAnimated:YES]

转到上一个控制器,但如果你必须转到不同的控制器,那么获取该控制器的引用并使用

[self.navigationController popToViewController:referenceOfYourVC animated:YES]

答案 2 :(得分:2)

[self.navigationController popViewControllerAnimated:YES]; 

上面的代码不应该带来错误但是你从堆栈弹出一个视图,视图的dealloc方法会自动调用。我相信您可能有一些与内存相关的问题,或者您正在视图的dealloc方法中释放一些零保留计数对象。

答案 3 :(得分:0)

是的问题是自动布局的某种错误/问题。我不确定它是什么,但我在其他地方遇到系统添加的控件(比如UISearchBar上的取消按钮)。我将整个项目转换为struts,它适用于所有相同的代码。

我会等到转换回来之前自动布局已经有一段时间了。

Strange Crash when dismissing view controller, auto-layout to blame?