繁体   English   中英

iOS 9上的自动布局崩溃,禁用了自动布局

[英]Auto-Layout crash on iOS 9 with auto-layout disabled

我知道这是一个通用的问题,但我希望有类似经历的人可能知道可能发生的事情。

我在仅限 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]));

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

在从超级视图中删除一些视图之后会出现异常,并且它确实显示NSISEngine错误,表明可能已为某些XIB或Storyboard打开了AutoLayout - 否则iOS会在内部使用AutoLayout来处理新布局的排列。

这个答案有一个几乎相同的堆栈跟踪,并指出使用不正确的手势方法处理firstResponder更改和解除键盘的问题。 如果你正在做类似的事情(忽略一些视图,编辑UITableView?),可能是错误的方法指向一个不存在的委托?

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

堆栈跟踪表示有关屏幕键盘的问题。 有一个布局更改,最终会有一个非exsistant委托。 看起来您的代码会直接或间接触发与键盘相关的布局更改。 事实是,即使您的应用程序确实重新输入,屏幕上的键盘也不会被磨碎。

至于iPad Pro和智能键盘,你可能有一个快速键,也可以隐藏。 有些应用程序存在外部键盘问题。

尝试将蓝牙键盘连接到您的某个测试设备。 将其连接到xcode,在exeptions上设置断点并尝试文本字段。 猜猜你会找到你想要的东西。

可能是您在启动它时可能拼错了任何viewcontroller或xib名称,或者您可能已更改,文件名称或移动它,在物理文件夹中忘记将其从xcode中删除。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM