Wednesday, 15 April 2015

ios - Clear the content of the UITextField's text property for tap -



ios - Clear the content of the UITextField's text property for tap -

i have uitextfield called place, it's text property contains nsstring. clear existing content text property when user taps text field.

i tried code above, nil happened. tried placeholder property, same. have thought problem? think should work.

- (void)textfielddidbeginediting:(uitextfield *)textfield { self.place.text = nil; }

2, version - in case nil appears in text field beginning

- (void)viewdidload { [super viewdidload]; ... [self textfielddidbeginediting:place]; } - (void)textfielddidbeginediting:(uitextfield *)textfield { textfield.text = nil; }

there property clearsonbeginediting can set yes programmatically or there checkbox in interface builder.

if want clear placeholder

- (void)textfielddidbeginediting:(uitextfield *)textfield { textfield.placeholder = nil; }

double check uitextfield self.place has it's delegate set view controller , validate textfielddidbeginediting beingness called.

ios objective-c

No comments:

Post a Comment