iOS 9上禁用Auto-Layout后Auto-Layout崩溃

5

我知道这是一个泛泛的问题,但我希望有类似经验的人能够了解可能发生的事情。

我们的仅限于iPad的应用程序在上发生了崩溃。它显示 NSInternalInconsistencyException

无论是在竖屏还是横屏模式下,在许多iPad版本上(如iPad 2、iPad Pro、iPad 4等)都会出现该问题。

我没有在项目中启用自动布局,但它看起来像是一个自动布局问题。

非常难以复制,所以我不能在Xcode上对其进行调试,但我在崩溃分析服务“Crashlytics”上看到了崩溃报告。以下是来自Crashlytics的堆栈跟踪:

Auto layout internal error. Cannot find an outgoing row 
head for incoming head <unknown var (bug!) with engine as delegate[...]

Thread : Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x23d4568b __exceptionPreprocess
1  libobjc.A.dylib                0x356c2e17 objc_exception_throw
2  CoreFoundation                 0x23d455d1 -[NSException initWithCoder:]
3  Foundation                     0x24a873b3 -[NSISEngine minimizeConstantInObjectiveRowWithHead:]
4  Foundation                     0x24a86e4d -[NSISEngine optimize]
5  Foundation                     0x24a82a53 -[NSISEngine withBehaviors:performModifications:]
6  UIKit                          0x27e040bb -[UIView(Hierarchy) _postMovedFromSuperview:]
7  UIKit                          0x280fb227 __UIViewWasRemovedFromSuperview
8  UIKit                          0x27e02ddb -[UIView(Hierarchy) removeFromSuperview]
9  UIKit                          0x282e5fa9 -[UIKeyboardPredictionView setPredictionViewState:animate:notify:]
10 UIKit                          0x281e3787 -[UIKeyboardImpl updatePredictionView]
11 UIKit                          0x27f155e3 -[UIKeyboardImpl finishLayoutChangeWithArguments:]
12 UIKit                          0x27e31437 -[UIKeyboardImpl updateLayout]
13 UIKit                          0x27e36077 -[UIKeyboardImpl setDelegate:force:]
14 UIKit                          0x27e2f6e1 -[UIPeripheralHost(UIKitInternal) _reloadInputViewsForResponder:]
15 UIKit                          0x27e2f20d -[UIResponder(UIResponderInputViewAdditions) reloadInputViews]
16 UIKit                          0x27e8d853 -[UIResponder becomeFirstResponder]
17 UIKit                          0x27e8db6d -[UIView(Hierarchy) becomeFirstResponder]
18 UIKit                          0x27f12289 -[UITextField becomeFirstResponder]
19 UIKit                          0x27fbe69f -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary]
20 UIKit                          0x27fbdc75 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:]
21 UIKit                          0x28334e27 _UIGestureRecognizerSendTargetActions
22 UIKit                          0x27fa2303 _UIGestureRecognizerSendActions
23 UIKit                          0x27e3a7af -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:]
24 UIKit                          0x28335f2f ___UIGestureRecognizerUpdate_block_invoke809
25 UIKit                          0x27dfc287 _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks
26 UIKit                          0x27df9e77 _UIGestureRecognizerUpdate
27 UIKit                          0x27e386f9 -[UIWindow _sendGesturesForEvent:]
28 UIKit                          0x27e37e43 -[UIWindow sendEvent:]
29 UIKit                          0x27e097e5 -[UIApplication sendEvent:]
30 UIKit                          0x27e07fdf _UIApplicationHandleEventQueue
31 CoreFoundation                 0x23d08c3f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
32 CoreFoundation                 0x23d0882d __CFRunLoopDoSources0
33 CoreFoundation                 0x23d06b9b __CFRunLoopRun
34 CoreFoundation                 0x23c5a249 CFRunLoopRunSpecific
35 CoreFoundation                 0x23c5a035 CFRunLoopRunInMode
36 GraphicsServices               0x2cd24ad1 GSEventRunModal
37 UIKit                          0x27e6f899 UIApplicationMain
38 Mr Appliance                   0xcda7b main (main.m:16)
39 libdyld.dylib                  0x35e0e873 start

问题在于我不知道代码中发生了什么。堆栈跟踪没有显示崩溃发生的代码位置,只显示了“main.m 16行”,即return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));

那么你希望我们对此做些什么呢?你有代码,而我们没有。此时此刻我们毫无头绪,而你却知道发生了什么。 - matt
我不指望你知道,但我希望有类似问题的人可能知道发生了什么,或者可能知道这是iOS中的一个错误。 - Carl
你有没有尝试在“Auto layout internal error. Cannot find an outgoing row”上搜索过? - matt
1
兄弟,我在Stackoverflow上提问的原因是因为我在其他地方搜索卡住了。我找到了这个问题(以及其他很多),但它并不适用于我的情况,因为我没有启用自动布局,并且我找不到任何“小(几乎为零)浮点数”(如最佳答案中建议的)。 - Carl
检查一下你是否使用了正确的标识符(名称是否正确),如果你正在使用自定义视图或单元格,这可能会导致崩溃。 - Bhavuk Jain
显示剩余4条评论
3个回答

1

main.m文件中的那一行是程序开始运行的地方,而不是出错的地方。异常是在列表的顶部 #1 抛出的,在所有其他项发生之后。问题出在两者之间。

当某个视图从其 superview 中移除后,就会出现异常,并且它确实显示了 NSISEngine 错误,表明可能为某些 XIB 或 Storyboard 打开了 AutoLayout - 或者 iOS 在内部使用 AutoLayout 处理新布局的排列。

这个答案 的堆栈跟踪几乎相同,并指出问题在于使用错误的手势方法来处理 firstResponder 更改和关闭键盘。如果您正在做类似的事情(关闭某个视图,编辑 UITableView?),也许是指向不存在的委托的错误方法?

https://stackoverflow.com/questions/33800918/uitextfield-becomefirstresponder-crashes-the-ios-app-randomly


在那个视图中(或整个应用程序中)我没有任何自定义手势方法。你给我的链接有一个相同的堆栈跟踪,只是他使用的是GlowingTextField,而我使用的是普通的UITextField。 - Carl

0
也许在初始化时您可能会拼错任何视图控制器或xib名称,或者您更改了文件名或将其移动到物理文件夹中,忘记从Xcode中删除它。

这不可能发生,因为这个崩溃只会在iOS 9上发生,也就是说使用iOS 7和8的用户不会遇到这个问题。 - Carl

0

堆栈跟踪指示屏幕键盘存在问题。布局更改导致不存在的委托。看起来您的代码直接或间接触发与键盘相关的布局更改。

问题在于,即使您的应用程序接收到输入,屏幕上的键盘也不会显示。

至于iPad Pro和Smart Keyboard,您可能会有一个快速输入栏,它也可以隐藏。相当多的应用程序都存在外部键盘的问题。

尝试将蓝牙键盘连接到其中一个测试设备。将其连接到Xcode,在异常处设置断点并尝试使用文本字段。猜测您会找到您要寻找的内容。


由于这是一款定制的B2B应用程序,我们知道用户不会使用外部键盘,至少不会使用26个按键,因此不能是外部键盘问题。但看起来像是屏幕键盘问题。 - Carl
你是否对屏幕布局有任何假设?或者这些用户在设备上安装了第三方键盘扩展吗? - Helge Becker
我将这些信息(用户是否使用第三方键盘)添加到Crashlytics报告中,并注意到没有一个用户使用第三方键盘。 - Carl

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接