Maverick Issue : While adding a subview on NSView

爱⌒轻易说出口 提交于 2020-01-25 11:44:04

问题


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.


回答1:


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

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


来源:https://stackoverflow.com/questions/20113498/maverick-issue-while-adding-a-subview-on-nsview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!