> On 27 Aug 2015, at 16:29, Ken Thomases <k...@codeweavers.com> wrote: > > On Aug 27, 2015, at 8:41 AM, Dave <d...@looktowindward.com> wrote: > >> I’m trying to setup a StackView inside a ScrollView, I’ve based by code on >> the InfoBarView and the TSInfoBarView sample Apps. Basically I have the >> following elements: >> >> LTWDetailWindowController This is the main Window Controller, the Window >> it controls is NOT resizable and has a size of 846 x 594. >> >> This is set up like so (in XCode): >> >> Objects >> OtherViewController This has a outlet “disclosedView” which >> is hooked up to the Detail View In the VCs (see below). > > It's rarely appropriate to instantiate a view controller as an object in a > NIB. Usually, it's instantiated in code and it loads and owns a view NIB. > It is therefore represented by the File's Owner placeholder in that view NIB.
It was/is like this in the Sample App which I followed. Basically I was trying to get it to work in my App without changing too much first. Once I got it working with one VC I was going to remove it from the NIB and create it in code. > From what you say below, you're going to want multiple instances of this view > controller and the view it represents. Instantiating it once in this NIB > doesn't help you achieve that. You'd have to archive and unarchive it in > order to make a new instance that's faithful to the original. Much easier to > put it into a NIB of its own and instantiate an instance of the controller > and have that load its NIB. See comment above. > >> >> DetailWindow >> View >> WindowHeaderView >> ImageView >> TextView -Setup with string data >> from Dictionary >> DetailScrollView (NSScrollView) >> Flipped Clip View >> View >> Scroller >> Scalar >> Button1 >> Button2 >> >> DetailView >> TextView1 -Setup with string data from >> Dictionary >> Left Button >> Right Button > >> The LTWDetailWindowController get instantiated, it gets an Array of >> Dictionaries from the Data Model. For each dictionary in the Array I want to >> add a OtherViewController instance to the StackView and then add the >> StackView to the DetailScrollView. When this happens I want the StackView >> and whatever it contains to auto-magically resize to fit the >> DetailScrollView Container Size. > > You want the stack view to size itself to match the scroll view? Why? That > would mean that the scroll view would never scroll, defeating the purpose of > its existence. Sorry match the width, the width is fixed and the horizontal scroller is disabled, I only want vertical scrolling. > The stack view should size itself to its content and, if that's too big to > show all at once in the scroll view, the scroll view should allow it to > scroll. See above, I want the StackView to grow vertically but not Horizontally. > > The document view of the scroll view should be the stack view itself. Your > diagram above just shows a plain view. You _can_ do that, but then you have > to manually add the stack view as that view's subview and add constraints to > make their edges coincide. That's not hard, but is harder than necessary. Not sure what you mean, I have a ScrollView, I create the StackView in code, add the one (for this test) DetailView to the StackView and then add the StackView to the Scroll view. When I have multiple DetailViews, I will create multiple VCs, add the Views to the StackView and then add the StackView (containing all the detail views) to the Scroll view. When this happens I want to to expand the details Views to fit the StackView and have it scroll in Y if the number of DetailViews warrants it. > > I recommend that you just make the stack view the document view and then > dynamically add your detail views to the stack view. That will largely > automate everything for you. > >> I decided to start at the top level (maybe a mistake), so I select the >> DetailView in the Window Controllers NIB and then click the Add New >> Constraints button at the bottom of the NIB window but I can’t select >> anything in the popup? The same is true for the Alignment. Why is this? My >> confusion is that surely I need to somehow tell it that DetailView that it >> needs to change size to fit it’s superview? > > First, if the detail view is going to go in a stack view, you should not > attempt to add any constraints between it and the stack view (its eventual > superview). > > In any case, you can't add constraints between a top-level view in a NIB and > its _eventual_ superview. You can only add constraints to an _actual_ > superview, which of course implies that the view isn't top-level. First, a > top-level view is expected to be (potentially) placed in various different > contexts by different controllers and it would be up to those controllers to > decide how it should fit into those contexts. Also, constraints can't be > added/activated if the views involved are not all in the same view hierarchy. > And when they are added, they are added to the common ancestor of all of the > involved views. So, such constraints as you're imagining would have nowhere > to be between the time the NIB is loaded and when it's added to a superview. I’ll re-read what this again tomorrow - my head hurts now! Thanks a lot for trying to help. 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