Nagasaki
Nagasaki

Reputation: 58

Replace UITextField Placeholder

I have a 'IBOutlet UITextField* textField' connect with a UITextField in a .xib file. I use this element as a combobox in a viewcontroller class which is connect to a VC in the storyboard. My question is how can i modify the placeholder text? I already try the 3 following methods, but nothing work!!

-(void) setPlaceholder:(NSString *)label
{
    textField.placeholder = label;
    [textField setPlaceholder:label];
    [textField cell ]setPlaceholderString:label];
}

thx for your answers

Upvotes: 1

Views: 5760

Answers (3)

user2295570
user2295570

Reputation:

put it in the viewdidload method of your viewcontroller method because the placeholder field wasn't initialize when i called my setPlaceholder method

Upvotes: 1

Zehn
Zehn

Reputation: 55

As long as you're textField has been synthesised, you should be able to use: textField.placeholder = label

Upvotes: 1

Ishank
Ishank

Reputation: 2926

textField.placeholder = @"placeholder" shall work, check if label and textField actually point to respective objects.

Upvotes: 0

Related Questions