This question already has answers here:
Cannot hide Controls in NSView
(2 answers)
Closed 9 years ago.
I am developing an application in cocoa.I need to hide a progress bar placed in an NSView
and show an NSTextfield in that place .I used the following cod
[progressbar setHidden:TRUE]
[textfield setHidden:FALSE];
But this code snippet is not working. Is that a bug.??I used to hide the same code to hide certain other text fields in the same page .But that controls became hidden.looking for a solution...
Are progressbar and textfield outlets ? If yes, make sure they are correctly connected in your nib. Also make sure that you call setHidden: from the main thread.
And unrelated to your problem, in Objective-C you should use YES instead of TRUE and NO instead of FALSE.
Related
This question already has answers here:
UIView vs UIViewController
(3 answers)
Closed 8 years ago.
I'm using a book on programming games in xcode to teach myself.
I downloaded some of the programs and tried to make my own codes using them, but i can't figure out how to create a mainview.h or mainview.m
Also how do these differ from view controller?
commandn -> Objective-C class -> Next
Class: mainview
Subclass of: UIView
-> Next -> Create
A view is an area where stuff can be draw (programatically using a view controller or visually in Interface Builder).
A view controller is a class that that controls how stuff is drawn in a view, it contains all the code and logic).
This question already has an answer here:
Cocoa - Capturing NSStatusItem mouse hover event
(1 answer)
Closed 8 years ago.
I've successfully added a NSStatusItem to the menu bar, showing an regular NSMenu.
Is it possible to capture a hover event on this and in that case, display a different menu?
You need to create a new custom view, override method [NSView mouseEntered:] with [NSView addTrackingRect:...] and then set to the status item [NSStatusItem setView:]
This question already has answers here:
What does the "Couldn't compile connection:" error mean?
(2 answers)
Closed 9 years ago.
I made a Dynamic UITableViewCell with an UImageView and an UILabel.
I linked items to code, build it and it gave me this alarm:
Couldn't compile connection: <IBCocoaTouchOutletConnection:0x7ff657212ee0 <IBProxyObject: 0x7ff6572e5e30> => nationLabel => <IBUILabel: 0x7ff6572e2bd0>>
I've never worked with dynamic cells so probably it's a stupid mistake of mine, but I can understand the reason of it.
How can I solve it? Thank you!
Sounds like you're trying to establish outlets from your prototype cell to your view controller. As mentioned in the comments, that isn't going to work because there are potentially multiple cells and they can't all be connected to the same outlet. So, the first thing you need to do is delete these outlet connections from the storyboard. Once you've done that, the code should compile. From there you have two options (well, I'm sure there are other ways to do this, but these are the normal ones):
In the storyboard, set unique values for the tag property for each element, e.g. make the image 1 and the label 2. In your view controller, anytime you need to access an element, you can do so by calling [self.view viewWithTag:].
Create a custom cell subclass of UITableViewCell, assign it to your prototype, and create outlets between the prototype and the subclass.
It sounds like you've tried (1) and got stuck. If you get stuck, just explain the specific issue you're having and someone will help you work it out.
This question already has answers here:
Respond to mouse events in text field in view-based table view
(6 answers)
Closed 9 years ago.
I have a view based NSTableView in which the cells contain a number of controls including text fields and edit fields. When a user tries to click on a control within a cell in order to, for example, start editing a text field, the click's main objective is ignored and the cell gets selected. Another click is then needed to perform the action originally intended, and even this click is subject to a delay before it's taken into account.
How can I avoid this problem and have the row selected and the mouse event forwarded to the control in one go?
I solved this issue by subclassing NSTableView:
#implementation QuickResponseTableView
- (BOOL)validateProposedFirstResponder:(NSResponder *)responder forEvent:(NSEvent *)event
{
// This allows the user to click on controls within a cell withough first having to select the cell row
return YES;
}
#end
Had the same problem. After much struggle, it magically worked when I selected None as against the default Regular (other option is Source List) for the Highlight option in IB! The accepted answer appears to be more specific but a little hacky compared to this.
My question is simple and easy; How do i get NSPopover to be first responder from the NSStatusbar?
I'm asking for a short code, not a link to a big XCode-project. Thanks.
Though you've probably solved your question by now, you can do this:
[yourPopover becomeFirstResponder];
If you want more control, just setup your containing controller for a NSPopoverDelegate.
[yourPopOver setDelegate:self]; /* Don't forget including the <NSPopoverDelegate> in your headerfile */
Then you can use 5 functions to gain more control over your popover.
– popoverShouldClose:
– popoverWillShow:
– popoverDidShow:
– popoverWillClose:
– popoverDidClose: