> > The NSLayoutFormatAlignAllLeft says that all the views mentioned in the > format string should be aligned along their left edges. Which isn’t possible > if you want them to be laid out horizontally. > You should just use 0 for options. > > However: StackView is the parent of DetailView so you should be using | as > the superview, so simply doing something like this should work. > > myConstraintsArray = [NSLayoutConstraint > constraintsWithVisualFormat:@“H:|[DetailView]|" options:0 metrics:nil > views:myConstraintsViewDictionary]; > [myDetailView addConstraints:myConstraintsArray]; > > iain
I tred this: myDetailView = [myDetailViewController getPrimaryView]; [self.pValidationListStackView addView:myDetailView inGravity:NSStackViewGravityTop]; myConstraintsViewDictionary = [[NSMutableDictionary alloc] init]; [myConstraintsViewDictionary setObject:self.pValidationListStackView forKey:@"StackView”]; [myConstraintsViewDictionary setObject:myDetailView forKey:@"DetailView”]; myConstraintsArray = [NSLayoutConstraint constraintsWithVisualFormat:@"H:|[DetailView]|" options:0 metrics:nil views:myConstraintsViewDictionary]; [myDetailView addConstraints:myConstraintsArray]; I assumeI don’t need to add StackView to the Dictionary but it won’t do any harm? When I run the above I get this error: Unable to install constraint on view. Does the constraint reference something from outside the subtree of the view? That's illegal. constraint:<NSLayoutConstraint:0x610000083de0 H:|-(0)-[LTWDetailXView] (Names: LTWDetailXView:0x608000181930, '|':NSStackViewContainer:0x6300001a0540 )> view:<LTWDetailXView: 0x608000181930> ]( 0 CoreFoundation 0x00007fff8f14f03c __exceptionPreprocess + 172 1 libobjc.A.dylib 0x00007fff91a3076e objc_exception_throw + 43 2 CoreFoundation 0x00007fff8f14eeed +[NSException raise:format:] + 205 3 Foundation 0x00007fff8d9e5e4e -[NSLayoutConstraint _addToEngine:integralizationAdjustment:mutuallyExclusiveConstraints:] + 183 4 AppKit 0x00007fff9529549c -[NSView(NSConstraintBasedLayout) _layoutEngine_didAddLayoutConstraint:integralizationAdjustment:mutuallyExclusiveConstraints:] + 89 5 AppKit 0x00007fff952951eb -[NSView(NSConstraintBasedLayout) _tryToAddConstraint:integralizationAdjustment:mutuallyExclusiveConstraints:] + 299 6 AppKit 0x00007fff95294f77 __50-[NSView(NSConstraintBasedLayout) addConstraints:]_block_invoke + 188 7 Foundation 0x00007fff8d9f148e -[NSISEngine withBehaviors:performModifications:] + 155 8 AppKit 0x00007fff951471aa -[NSView(NSConstraintBasedLayout) _withAutomaticEngineOptimizationDisabled:] + 70 9 AppKit 0x00007fff95186c6c -[NSView(NSConstraintBasedLayout) addConstraints:] + 279 10 ClassifierForMac 0x0000000100013a3e -[LTWValidationWindowController awakeFromNib] + 2206 11 AppKit 0x00007fff9513f079 -[NSIBObjectData nibInstantiateWithOwner:options:topLevelObjects:] + 1276 12 AppKit 0x00007fff9511e0e5 loadNib + 384 13 AppKit 0x00007fff9511d60b +[NSBundle(NSNibLoading) _loadNibFile:nameTable:options:withZone:ownerBundle:] + 313 14 AppKit 0x00007fff952ccbf7 +[NSBundle(NSNibLoadingInternal) _loadNibFile:externalNameTable:options:withZone:] + 150 15 AppKit 0x00007fff952cc99d -[NSWindowController loadWindow] + 313 16 AppKit 0x00007fff952c7b65 -[NSWindowController window] + 80 17 ClassifierForMac 0x0000000100013cc3 -[LTWValidationWindowController startUp] + 51 18 ClassifierForMac 0x000000010003d1b7 -[BJDebugWindowController performTestGUI:] + 375 19 libsystem_trace.dylib 0x00007fff8e4ebcd7 _os_activity_initiate + 75 20 AppKit 0x00007fff95367eb1 -[NSApplication sendAction:to:from:] + 452 21 AppKit 0x00007fff9537d946 -[NSControl sendAction:to:] + 86 22 AppKit 0x00007fff9537d862 __26-[NSCell _sendActionFrom:]_block_invoke + 131 23 libsystem_trace.dylib 0x00007fff8e4ebcd7 _os_activity_initiate + 75 24 AppKit 0x00007fff9537d7bf -[NSCell _sendActionFrom:] + 144 25 libsystem_trace.dylib 0x00007fff8e4ebcd7 _os_activity_initiate + 75 26 AppKit 0x00007fff9537bcb3 -[NSCell trackMouse:inRect:ofView:untilMouseUp:] + 2821 27 AppKit 0x00007fff953d434f -[NSButtonCell trackMouse:inRect:ofView:untilMouseUp:] + 770 28 AppKit 0x00007fff9537a366 -[NSControl mouseDown:] + 714 29 AppKit 0x00007fff958e42dc -[NSWindow _reallySendEvent:isDelayedEvent:] + 14125 30 AppKit 0x00007fff95273c86 -[NSWindow sendEvent:] + 470 31 AppKit 0x00007fff95270212 -[NSApplication sendEvent:] + 2504 32 AppKit 0x00007fff95199b68 -[NSApplication run] + 711 33 AppKit 0x00007fff95116244 NSApplicationMain + 1832 34 L 0x0000000100000f92 main + 34 35 libdyld.dylib 0x00007fff920285c9 start + 1 ) Any idea what could be wrong? Thanks a lot for your help on this. All the Best Dave _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com