Hide/Show all objects in a NSWindow - Cocoa

杀马特。学长 韩版系。学妹 提交于 2019-12-13 02:49:14

问题


Quick question. How can I hide and then show all the objects in a NSWindow without doing something terribly tedious and complicated?

Kevin


回答1:


I may be late to this particular party, but how about this?

[[window contentView] setHidden:YES];

And conversely...

[[window contentView] setHidden:NO];

That's certainly less tedious and complicated. :D




回答2:


for(NSView* view in [[window contentView] subviews])
{
    [view setHidden:YES];
}



回答3:


Assuming everything is a NSView:

//Hide views
for (NSView *view in [[myWindow contentView] subviews]) {
   [view setHidden:YES];
}


//Show views
for (NSView *view in [[myWindow contentView] subviews]) {
   [view setHidden:NO];
}

You will probably need to call a setNeedsDisplay somewhere.

EDITED Sorry, been working in Ruby all day. Edited to make it Objective C :)

Untested, but should get you started.



来源:https://stackoverflow.com/questions/6756277/hide-show-all-objects-in-a-nswindow-cocoa

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