Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS8中的自动布局崩溃_Ios_Objective C_Uiscrollview_Autolayout - Fatal编程技术网

iOS8中的自动布局崩溃

iOS8中的自动布局崩溃,ios,objective-c,uiscrollview,autolayout,Ios,Objective C,Uiscrollview,Autolayout,以编程方式从xib向UIScrollView添加子视图,并启用autolayout。接收碰撞: 2015-02-25 22:21:25.829 EAIntroView[5215:1435025] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]' *** First t

以编程方式从
xib
UIScrollView
添加子视图,并启用
autolayout
。接收碰撞:

2015-02-25 22:21:25.829 EAIntroView[5215:1435025] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 5 beyond bounds [0 .. 4]'
*** First throw call stack:
(
    0   CoreFoundation                      0x000000010c1f4f35 __exceptionPreprocess + 165
    1   libobjc.A.dylib                     0x000000010be8dbb7 objc_exception_throw + 45
    2   CoreFoundation                      0x000000010c0dff33 -[__NSArrayM objectAtIndex:] + 227
    3   UIKit                               0x000000010c87b5b1 _UIViewTopDownSubtreeTraversal + 193
    4   UIKit                               0x000000010ceacee6 -[UIView(UIConstraintBasedLayout_EngineDelegate) _invalidateSystemLayoutSizeFittingSizeAtEngineDelegateLevel] + 128
    5   Foundation                          0x000000010ba319bf -[NSISEngine tryToAddConstraintWithMarker:expression:integralizationAdjustment:mutuallyExclusiveConstraints:] + 915
    6   Foundation                          0x000000010bbbb0f8 -[NSLayoutConstraint _addLoweredExpression:toEngine:integralizationAdjustment:lastLoweredConstantWasRounded:mutuallyExclusiveConstraints:] + 275
    7   Foundation                          0x000000010ba2611a -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 220
    8   UIKit                               0x000000010cea9de5 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 474
    9   Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    10  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    11  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    12  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    13  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    14  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    15  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    16  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    17  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    18  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    19  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    20  UIKit                               0x000000010c8a568b -[UIScrollView _switchToLayoutEngine:] + 69
    21  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    22  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    23  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    24  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    25  UIKit                               0x000000010cea9ce4 __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke_2 + 217
    26  Foundation                          0x000000010ba33d6e -[NSISEngine withBehaviors:performModifications:] + 155
    27  UIKit                               0x000000010cea9beb __57-[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:]_block_invoke + 452
    28  UIKit                               0x000000010cea99fe -[UIView(AdditionalLayoutSupport) _switchToLayoutEngine:] + 197
    29  UIKit                               0x000000010cea9671 -[UIView(AdditionalLayoutSupport) _initializeHostedLayoutEngine] + 404
    30  UIKit                               0x000000010ce9e591 -[UIView(UIConstraintBasedLayout) _layoutEngine_windowDidChange] + 127
    31  UIKit                               0x000000010c8984a5 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 207
    32  UIKit                               0x000000010c891112 __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 125
    33  UIKit                               0x000000010c891086 -[UIView(Hierarchy) _postMovedFromSuperview:] + 437
    34  UIKit                               0x000000010c89af4b -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1604
    35  UIKit                               0x000000010cabfe84 -[UILayoutContainerView addSubview:] + 75
    36  EAIntroView                         0x000000010b93e14a -[EAIntroView showInView:animateDuration:withInitialPageIndex:] + 362
    37  EAIntroView                         0x000000010b93dfc9 -[EAIntroView showInView:animateDuration:] + 121
    38  EAIntroView                         0x000000010b9303a7 -[ViewController showIntroWithCustomViewFromNib] + 1879
    39  EAIntroView                         0x000000010b9326a4 -[ViewController tableView:didSelectRowAtIndexPath:] + 340
    40  UIKit                               0x000000010c90c393 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1293
    41  UIKit                               0x000000010c90c4d4 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 219
    42  UIKit                               0x000000010c847331 _applyBlockToCFArrayCopiedToStack + 314
    43  UIKit                               0x000000010c8471ab _afterCACommitHandler + 516
    44  CoreFoundation                      0x000000010c129dc7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    45  CoreFoundation                      0x000000010c129d20 __CFRunLoopDoObservers + 368
    46  CoreFoundation                      0x000000010c11fb53 __CFRunLoopRun + 1123
    47  CoreFoundation                      0x000000010c11f486 CFRunLoopRunSpecific + 470
    48  GraphicsServices                    0x00000001106f59f0 GSEventRunModal + 161
    49  UIKit                               0x000000010c824420 UIApplicationMain + 1282
    50  EAIntroView                         0x000000010b932843 main + 115
    51  libdyld.dylib                       0x000000010e9c7145 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
无论在
xib
中是否存在任何自动布局约束。将自动布局约束添加到以编程方式创建的子视图(没有
xib
)会导致相同的崩溃

但是:如果我们在不使用任何自动布局的情况下创建和显示自定义视图,则使用autolayout
xib
,隐藏它并创建新视图-即使在所有约束都有效的情况下,它也能完美地工作

有关问题:

该问题的解决办法:

关闭所有XIB的自动布局解决了此问题


GitHub上的所有代码、示例项目和相关问题:

我终于找到了这个问题的根本原因:
子视图
在我的
UIScrollView
子类()中的属性重写


Autolayout以某种方式使用了子视图属性,覆盖它会破坏一切。这是不一致的,并且取决于许多其他因素,但修复
子视图
在100%的情况下都能为我解决这个问题。

什么是u nsarray?你能给我们看一下你的代码吗,在链接中找不到这个链接导致了GitHub上的回购问题。它描述了如何重现崩溃。演示项目就在repo中。而且,
\u NSArrayM
是可变数组的私有类。可能是