删除NSWindow内容视图 [英] Remove NSWindow content view

查看:215
本文介绍了删除NSWindow内容视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为以下窗口设置了内容视图,现在我要删除该内容视图,并将其设置为其他内容。我试图只是设置内容视图到另一个视图,并没有工作,我怎么可以删除它?谢谢!

I set the content view for the following window and now i want to remove that content view and set it to something else. I tried just setting the content view to another view and that did not work, how can i just remove it? thanks!

    controlFilterBox = [[MoveFilter alloc] initWithFrame:helpWindow.frame];
    [helpWindow setContentView:controlFilterBox];
    [controlFilterBox release];


推荐答案

您不能删除contentView到 nil )。窗口需要一个视图。你可能可以通过调用 [controlFilterBox setNeedsDisplay:YES] 得到你想要做的,但我通常建议,而不是搞乱 contentView 本身,你想要交换的视图是 contentView 的子视图。然后你可以使用 removeFromSuperview addSubview:将它们作为正常视图进行交换。这通常比处理像 contentView 这样的特殊视图更容易。

You can't remove the contentView (i.e. set it to nil). The window requires a view. You probably can get what you're trying to do by calling [controlFilterBox setNeedsDisplay:YES], but I typically recommend that rather than messing with contentView itself, you make the views you want to swap to be subviews of contentView. Then you can just swap them around as normal views with removeFromSuperview and addSubview:. It's just often easier than dealing with a special view like contentView.

这篇关于删除NSWindow内容视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆