tags:

views:

208

answers:

3

Hi , 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]

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

[btn isHidden]

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

Thanks in advance.

A: 

Please try running the runloop once after hiding the button:

 [[NSRunLoop currentRunLoop] runUntilDate:[NSDate dateWithTimeIntervalSinceNow:1]];
Diederik Hoogenboom
+1  A: 

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.

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.

Jon Steinmetz
+1  A: 

You should rather edit your SetHidden not working question rather than asking a new one. Please see the What if I don't get a good answer? FAQ entry.

0xced