Closed m1entus closed 8 years ago
Try downloading the project again. It's likely you accidentally changed something, or I didn't recreate your crash steps correctly:
I am testing on iOS 8.1 simulator (iOS9 works fine because it is native UIStackView implementation), issue still exists even on different mac, haven't touch anything in source code
Violence to solve:
InFDStackViewAlignmentLayoutArrangement.m
file, atupdateCanvasConnectionConstraintsIfNecessary
method, add@try
[canvasAttributes enumerateObjectsUsingBlock:^(NSNumber * _Nonnull canvasAttribute, NSUInteger idx, BOOL * _Nonnull stop) {
@try {
NSLayoutAttribute attribute = canvasAttribute.integerValue;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:[self viewOrGuideForLocationAttribute:attribute] attribute:attribute relatedBy:[self layoutRelationForCanvasConnectionForAttribute:attribute] toItem:self.canvas attribute:attribute multiplier:1 constant:0];
constraint.identifier = @"FDSV-canvas-connection";
[self.canvas addConstraint:constraint];
[self.canvasConnectionConstraints addObject:constraint];
}
@catch (NSException *exception) {
NSLog(@"%@", exception.reason);
}
@finally {
}
}];
The new code has solved
Thanks
Use Storyboard mode, add view, remove view, add view then crash:
2015-10-11 14:02:00.085 FDStackViewDemo[6976:177315] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Impossible to set up layout with view hierarchy unprepared for constraint.' * First throw call stack: ( 0 CoreFoundation 0x0000000103216f35 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000102eb1bb7 objc_exception_throw + 45 2 CoreFoundation 0x0000000103216d9a +[NSException raise:format:arguments:] + 106 3 Foundation 0x0000000102acf5df -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 195 4 UIKit 0x000000010412bcf2 120-[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:]_block_invoke_2 + 177 5 UIKit 0x000000010412bbe7 -[UIView(UIConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 377 6 UIKit 0x000000010412bea4 -[UIView(UIConstraintBasedLayout) _tryToAddConstraintWithoutUpdatingConstraintsArray:roundingAdjustment:mutuallyExclusiveConstraints:] + 30 7 UIKit 0x000000010412bfcc -[UIView(UIConstraintBasedLayout) _tryToAddConstraint:roundingAdjustment:mutuallyExclusiveConstraints:] + 243 8 FDStackViewDemo 0x0000000102967e66 -[FDStackViewDistributionLayoutArrangement resetFillEffect] + 1750 9 FDStackViewDemo 0x0000000102969979 -[FDStackViewDistributionLayoutArrangement resetAllConstraints] + 57 10 FDStackViewDemo 0x0000000102969ecb -[FDStackViewDistributionLayoutArrangement updateCanvasConnectionConstraintsIfNecessary] + 43 11 FDStackViewDemo 0x000000010296a57b -[FDStackViewLayoutArrangement updateArrangementConstraints] + 43 12 FDStackViewDemo 0x000000010296658a -[FDStackView updateLayoutArrangements] + 186 13 FDStackViewDemo 0x0000000102965bd5 -[FDStackView addArrangedSubview:] + 501 14 FDStackViewDemo 0x000000010296f40b -[FDStoryboardBasedViewController addAction:] + 779 15 UIKit 0x0000000103ab28be -[UIApplication sendAction:to:from:forEvent:] + 75 16 UIKit 0x0000000103bb9410 -[UIControl _sendActionsForEvents:withEvent:] + 467 17 UIKit 0x0000000103bb87df -[UIControl touchesEnded:withEvent:] + 522 18 UIKit 0x0000000103e5f540 _UIGestureRecognizerUpdate + 9487 19 UIKit 0x0000000103af7ff6 -[UIWindow _sendGesturesForEvent:] + 1041 20 UIKit 0x0000000103af8c23 -[UIWindow sendEvent:] + 667 21 UIKit 0x0000000103ac59b1 -[UIApplication sendEvent:] + 246 22 UIKit 0x0000000103ad2a7d _UIApplicationHandleEventFromQueueEvent + 17370 23 UIKit 0x0000000103aae103 _UIApplicationHandleEventQueue + 1961 24 CoreFoundation 0x000000010314c551 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 25 CoreFoundation 0x000000010314241d CFRunLoopDoSources0 + 269 26 CoreFoundation 0x0000000103141a54 CFRunLoopRun + 868 27 CoreFoundation 0x0000000103141486 CFRunLoopRunSpecific + 470 28 GraphicsServices 0x00000001073959f0 GSEventRunModal + 161 29 UIKit 0x0000000103ab1420 UIApplicationMain + 1282 30 FDStackViewDemo 0x000000010296a7ff main + 111 31 libdyld.dylib 0x0000000105c3e145 start + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException