Hi, I'm having problems with vertical NSSplitViews in Lion. I'm dynamically adding subviews and nesting horizontal and vertical NSSplitViews. I don't get these problems in Snow Leopard.
Splitting horizontally seems to work fine, but splitting vertically causes several problems: - divider width is (sometimes) way too large - sometimes the divider is not shown at all - splitting time increases with number of subviews (10s with ~20 subviews) - the subview frames gets messed up and the following is printed in the console (here the two subviews overlap): 2011-09-23 11:54:28.745 splits[52596:707] <NSSplitView: 0x1003c8c80>: -resizeSubviewsWithOldSize: was invoked and left the subview frames in an inconsistent state: 2011-09-23 11:54:28.746 splits[52596:707] Split view bounds: {{0, 0}, {208, 215}} 2011-09-23 11:54:28.746 splits[52596:707] Subview frame: {{0, 0}, {94, 215}} 2011-09-23 11:54:28.747 splits[52596:707] Subview frame: {{89, 0}, {119, 215}} 2011-09-23 11:54:28.747 splits[52596:707] The subview frames are not in the same order as the subviews array. NSSplitView requires that these orders be kept consistent, otherwise behavior is undefined. I've made a minimal test project that shows the issue. It's available at http://bzero.se/splits.zip. This code does not use a delegate for the split view, so it can't be that I'm doing something weird in [splitView:resizeSubviewsWithOldSize:]. The core of the code is the method that splits the content views (which contain a single NSTextView): - (NSViewController *)splitView:(NSViewController *)viewController withView:(NSViewController *)newViewController vertically:(BOOL)isVertical { NSView *view = [viewController view]; NSView *newView = [newViewController view]; NSSplitView *split = (NSSplitView *)[view superview]; /* If there is only one subview in the split, convert it to the desired orientation. */ if ([[split subviews] count] == 1 && [split isVertical] != isVertical) [split setVertical:isVertical]; if ([split isVertical] == isVertical) { /* Same orientation, just add another view to this split. */ [split addSubview:newView]; } else { /* * Different orientation, replace the view with a new split view * containing the new and old content views. */ NSSplitView *newSplit = [[NSSplitView alloc] initWithFrame:[view frame]]; [newSplit setVertical:isVertical]; [newSplit setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; [newSplit setAutoresizesSubviews:YES]; [split replaceSubview:view with:newSplit]; [newSplit addSubview:view]; [newSplit addSubview:newView]; [newSplit release]; } [window makeFirstResponder:newView]; [views addObject:newViewController]; return newViewController; } Am I doing something wrong with the subviews? TIA .martin _______________________________________________ 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com