我知道这是一个普遍的问题,但我希望有类似经历的人可能知道可能会发生什么。
我在仅限iPad的应用中遇到了仅在iOS 9 上发生的崩溃。它表示 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]));
。
答案 0 :(得分:1)
main.m
中的那一行是程序开始运行的地方,而不是错误发生的地方。在所有其他项目发生后,在列表顶部的#1处抛出异常。问题出在两者之间。
一些视图从其超级视图中删除后出现异常,它确实显示NSISEngine错误,表明某些XIB或Storyboard可能已启用AutoLayout - 或者iOS在内部使用AutoLayout来处理新的布局。
This answer具有几乎相同的堆栈跟踪&amp;指出使用不正确的手势方法处理firstResponder更改和解除键盘的问题。如果您正在做类似的事情(忽略某些视图,编辑UITableView?),可能是因为错误的方法指向了一个不存在的代理?
https://stackoverflow.com/questions/33800918/uitextfield-becomefirstresponder-crashes-the-ios-app-randomly
答案 1 :(得分:0)
堆栈跟踪表示有关屏幕键盘的问题。有一个布局更改,最终会有一个非exsistant委托。看起来您的代码会直接或间接触发与键盘相关的布局更改。 事实是,即使您的应用程序确实重新输入,屏幕上的键盘也不会被磨碎。
对于iPad Pro和智能键盘,您可能有一个快速键,也可以隐藏。有些应用程序存在外部键盘问题。
尝试将蓝牙键盘连接到您的某个测试设备。将其连接到xcode,在exeptions上设置断点并尝试文本字段。猜猜你会找到你想要的东西。
答案 2 :(得分:0)
可能是您在启动它时可能拼错了任何viewcontroller或xib名称,或者您可能已更改,文件名或移动它,在物理文件夹中忘记将其从xcode中删除。