views:

235

answers:

3

I really enjoy using RBSplitView, an open source replacement for NSSplitView, but I have a problem in my shipping app and am experiencing it again in a new project.

The problem is I'm telling the RBSplitView to autosave its position state by giving it an autosave name. When my app launches the RBSplitView doesn't seem to honor the saved state till a second after the window is drawn.

I've spent the night trying to debug the behavior but have had little success. Anyone out there use this lib and have some advice?

You can scrub this quicktime movie to the issue at work:

http://media.clickablebliss.com/billable/interface_experiments/rbsplitview_delayed_autosave_reload2.mov

+1  A: 

I've still been unable to figure out why this is happening but I do have a workaround.

First, make sure your main window is not visible at launch and then at the end of applicationDidFinishLaunching in your app delegate add something like:

[mainWindow performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay: 0.1];

The delay is the key. If you just tell the window to makeKeyAndOrderFront: I still see the issue. However as long as it has a beat of time it looks good.

Thanks for sharing that workaround.
Georg
A: 

This likely is happening because the RBSplitView instance needs to wait until it's first moment to get to set its frame to the autosaved value, which happens to be after the user can see it. This 0.0-delay trick simply delays showing the window until the very next runloop, which gives the split view a chance to do its magic (and other views) so that when the user sees the window, it's already nice and sexy. So just do the delay at 0.0 and you'll be fine.

A: 

I have a similar, but slightly different workaround in my app that uses RBSplitView. In applicationDidFinishLaunching:, I call adjustSubviews on the split view before calling makeKeyAndOrderFront: on the window that contains it. This seems to knock the split view in to order before it gets displayed on the screen.

Brian Webster