Re: NSSplitView question - how to implement my own "adjustViews" style method
Re: NSSplitView question - how to implement my own "adjustViews" style method
- Subject: Re: NSSplitView question - how to implement my own "adjustViews" style method
- From: Andy Lee <email@hidden>
- Date: Tue, 03 Jul 2012 10:03:30 -0400
I haven't used RBSplitView, but it sounds like it might be handy to have a method for replacing an already-set-up NSSplitView with an RBSplitView. Maybe it could be a category method on NSSplitView, something like this:
- (RBSplitView *)replaceWithRBSplitView
{
// Retain and autorelease self, to avoid premature dealloc.
// Create an RBSplitView instance with the same frame as self.
// Move self's subviews to the RBSplitView, preserving their frames.
// I'm not sure if simply sending addSubview: to the RBSplitView works,
// or if you have to explicitly remove the subviews from the NSSplitView.
// To be safe I'd assume the latter, and again be careful about
// premature dealloc.
// Set the RBSplitView's delegate to self's delegate.
// Send replaceSubview:with: to [self superview].
// Return the RBSplitView.
}
This way you can still use IB to lay out the subviews of the split view, using a regular NSSplitView. In awakeFromNib, you can swap out the split view by calling this method.
I think I'd try this approach if I was in a similar situation.
--Andy
On Jul 3, 2012, at 7:21 AM, Rainer Brockerhoff wrote:
>
> On Jul 3, 2012, at 01:46 , email@hidden wrote:
>> Date: Tue, 03 Jul 2012 10:14:21 +1000
>> From: Graham Cox <email@hidden>
>> Message-ID: <email@hidden>
>>
>> On 03/07/2012, at 12:21 AM, Motti Shneor wrote:
>>
>>> I really need an advice here.
>>
>> This will sound flippant but it's not meant to be: implement your own split view.
>
> RBSplitView will do exactly what you want. However, unfortunately it's stuck in the times when IB was a separate app with plugins. If you can manage to set up your views in code (at least the split view and its subviews, then pull in the rest), it still seems to work well.
>
> If you want to roll your own, my advice would be to at least glance at the RBSplitView code (and docs) beforehand. Looking back, the crucial decision seems to have been to implement RBSplitSubviews to handle most of the work.
>
> Good luck, ;-)
> --
> Rainer Brockerhoff <email@hidden>
> Belo Horizonte, Brazil
> "In the affairs of others even fools are wise
> In their own business even sages err."
> Weblog: http://www.brockerhoff.net/blog
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden