开发者

NSView overlapping

My cocoa app has a "dashboard" style layout. When the app starts, the main window contains 6 views which display graphs. When I click on any part of the bottom most view开发者_如何学C, I have another NSView instance popping up as an annotation. The problem I run into is that is the pop up NSView is large enough dimension wise, the other views in the window overlap the pop up view. Currently, I do that with: [[self superview] addSubview:annotationView ]; where 'superview' is the window. Im not sure why this would be the case, I have tried removing the the pop up view from the "view stack" and making it change positions but that didnt work.


[[[self window] contentView] insertView:popupView atIndex:0];

This will insert the view at the top level, if you still can't see it you will need to add a subview to the superview of the NSWindow's contentview.


If all the views are added as subviews of [self superview] then you must make sure that they do not overlap. Cocoa doesn’t guarantee correct behaviour in case there are overlapping sibling views.

If you want a popup view, consider using a child window instead. Since it’s a different window, the popup lies in a different view hierarchy, hence you won’t have the overlapping sibling views problem.

A good example of using child windows for additional information is Matt Gemmell’s MAAttachedWindow.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜