doc92606
doc92606

Reputation: 701

How to keep Placeholders even after clearing all textfields

So I have 3 textfields. After they are cleared, I would like the placeholder to STILL remain there. So far for about the past week I've been fighting with this issue and no one is able to help me solve it. I was wondering if this is even possible?...

Here is my sample code to set the placeholder after clearing it:

personYouOweMoney.text = @" ";
amtYouOwe.text = @" ";
self.cellNum.text = @" ";

personYouOweMoney.placeholder = @"Name of person you owe";
amtYouOwe.placeholder = @"Amount Owed (USD)";
self.cellNum.placeholder = @"Their cell number";

All help is appreciated, thanks in advance

Upvotes: 0

Views: 100

Answers (1)

staticVoidMan
staticVoidMan

Reputation: 20274

You are basically setting the textField's text to a single space so, technically, it ain't empty.
(Only when the textField is empty will the placeholder will be seen)

Do:

//set the placeholder's and when you want to clear the textfield, this...
personYouOweMoney.text = @"";
amtYouOwe.text = @"";
self.cellNum.text = @"";

Upvotes: 5

Related Questions