无法在NSView中隐藏控件 [英] Cannot hide Controls in NSView

查看:135
本文介绍了无法在NSView中隐藏控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发可可中的应用程序。现在,我面临一个关键问题。我无法在NSView中隐藏控件NSButton。我使用了以下代码

I am developing an application in cocoa. Now I am facing a critical issue. I can't hide controls NSButton in NSView. I used the following code

[btn setHidden:YES]

,但是此 btn控件并未隐藏。我使用以下代码检查按钮是否隐藏

but this "btn" control is not becoming hidden. I used the following code to check whether the button is hidden

[btn isHidden]

,但是返回YES。同样,在显示此视图时,我无法向NSTextfield发送值。

but this return YES. Also I can't sent a value to NSTextfield while showing this view.

预先感谢。

推荐答案

不知道应用程序中还发生了什么,很难知道为什么这不会使按钮隐藏。

Without knowing what else is going on in the application it is hard to know why this would not be making the button hidden.

是您阻止主事件循环,以便不处理更新事件?通常,这不是一件好事。

Are you blocking the main event loop such that the update events are not getting handled? Generally this is not a good thing to do.

可以强制执行立即更新的一件事是在按钮或其父视图或窗口上调用displayIfNeeded。这将导致重新绘制视图。这适合作为验证按钮将绘制(或不绘制)其正确状态的实验。如果调用displayIfNeeded确实导致它消失,那么您将需要确定为什么未正确处理更新事件。

One thing you can do to force an immediate update is to call displayIfNeeded on the button or its parent view or window. This should cause the view to be redrawn. This would be suitable as an experiment to validate that the button will draw (or not draw) its correct state. If calling displayIfNeeded does cause it to disappear then you will need to determine why update events are not getting handled correctly.

这篇关于无法在NSView中隐藏控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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