Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

cocoa - Maverick Issue : While adding a subview on NSView

I have a NSView(outlet - detailsView) , upon that a NSSplitView (outlet - detailsSpiltView) and there are two subviews in the split view and in those subview there are different scroll view and table view.

NSView(detailsView)
|
NSSplitView(detailsSplitView)
|           |
NSView      NSView
|                 |
NSScrollView      NSScrollView
|                 |
NSTableView       NSTableVIew

On a certain condition I am adding a an error view on detailsView and on other conditions the table view would be populated: The code for loading errorView is the following:

[self.errorView setFrame:[self.detailsSplitView frame]];
[self.errorView setBackgroundColor:ERR_BG_COLOR];
[self.errorView setAlphaValue:0.85];
[self.detailsView addSubview:self.errorView];

Its working perfectly in Mountain Lion but in Maverick the errorView is getting loaded behind the table views. I even tried to send the table views in back using code

[tableView1 sendToBack];
[tableView2 sendToBack];
[self.detailsView addSubview:self.errorView positioned:NSWindowAbove relativeTo:self.detailsSplitView]; 

But still errorview is loading in the back of tableview.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I added the following code beneath the addSubView method and it worked:

--------
[self.detailsView addSubview:self.errorView];
[self.errorView setWantsLayer:YES];

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...