I set the placeholder text of my NSTextField in Interface Builder, but the placeholder text doesn't show until I click inside the text field to edit it.
16
votes
That sounds like the exact opposite of what should happen. The placeholder text should disappear when the field is being edited. How have you set up your NSTextField? Is it bound to anything? Note that the placeholder string will only be shown if the stringValue of the text field is nil or @"".
- Stephen Poletto
There is no binding for the text field and its empty too. I've edited my post to show screenshots of the editing/not editing states.
- indragie
I have the same issue, did you find your answer?
- Nathan H
3 Answers
28
votes
20
votes
-2
votes
This is how I solve this problem:
- Subclass
NSTextFieldCell; - Override
- (void)drawWithFrame:(NSRect)cellFrame,- (void)drawInteriorWithFrame:(if need) method(s) ofNSCelland put all drawing code you need to those methods. Don't forget to callsuperimplementation; - Set
Classfield ofNSTextFieldCellinInterface Builderto your subclass; - Setup
borderin.xibfile to
(I don't know name of this border); - Turn off
Draw Background;