iOS 8上的NSRangeException [英] NSRangeException on iOS 8

查看:257
本文介绍了iOS 8上的NSRangeException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将XCode 5升级到6,以便在iPhone 6和6 Plus上测试我的项目,并在启动时遇到神秘的崩溃:

I upgraded XCode 5 to 6 to test my projects out on the iPhone 6 and 6 Plus and was getting cryptic crashes on startup:

'*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010569b3f5 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x0000000104b20bb7 objc_exception_throw + 45
    2   CoreFoundation                      0x00000001055864d3 -[__NSArrayM objectAtIndex:] + 227
    3   UIKit                               0x00000001028164e1 _UIViewTopDownSubtreeTraversal + 193
    4   UIKit                               0x0000000102e43286 -[UIView(UIConstraintBasedLayout_EngineDelegate) _invalidateSystemLayoutSizeFittingSizeAtEngineDelegateLevel] + 128
    5   Foundation                          0x0000000103aa66df -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 915
    6   Foundation                          0x0000000103c2f678 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
    7   Foundation                          0x0000000103a9ae3a -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 220
    8   UIKit                               0x0000000102e40495 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
    9   Foundation                          0x0000000103aa8a8e -[NSISEngine withBehaviors:performModifications:] + 155
    10  UIKit                               0x0000000102e4029b __57-[UIView(AdditionalLayoutSupport) 

经过大量试验和错误以及在各种配置中尝试各种XIB后,问题出现了,因为我正在混合一些打开自动布局的XIB,包含其他UIV关闭AutoLayout的iews(基于XIB)。

After a LOT of trial and error and trying various XIBs in various configurations, the issue occurred because I was mixing some XIBs with Auto Layout turned on, containing other UIViews (based on XIBs) with AutoLayout off.

关闭所有XIB的AutoLayout解决了这个问题。

Turning AutoLayout off for all of my XIBs solved the issue.

推荐答案

我找到的一个解决方案是你需要至少有6个屏幕然后应用程序不会崩溃。

One solution I found is that you need to have at least 6 screens and then the app won't crash.

仍然试图让它用更少的屏幕工作。
关闭我唯一的XIB(LaunchScreen.xib)上的自动布局,但这并没有解决问题。

Still trying to get it to work with less screens. Turned off Auto Layout on my only XIB (LaunchScreen.xib) but that didn't solve the problem.

这篇关于iOS 8上的NSRangeException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆