Reputation: 245
Hi I'm new in iPhone development, how do you disable a UITextField in iPhone development? If it matters, it is a View-Based Application, and the UITextField is named abc.
Thanks
Upvotes: 6
Views: 10215
Reputation: 77183
If you want to hide it completely:
abc.hidden = YES;
If you just want to prevent user interaction:
abc.userInteractionEnabled = NO;
Since UITextField is a subclass of UIView (and UIControl), all the UIView (and UIControl) methods (such as those I used above) are available.
Upvotes: 14
Reputation: 5940
You can do this a few ways.
abc.alpha = 0; //text field is there, just transparent, so it can't be seen.
abc.hidden = TRUE; // textfield is hidden, not on View at all.
abc.userInteractionEnabled = FALSE; // user can see the text field and any text
// that has already been set but cannot edit
Upvotes: 3
Reputation: 13753
You use [abc setEnabled:NO]
to disallow the user to edit it, or setHidden
to completely hide it
Upvotes: 2
Reputation: 13267
[textField setHidden:YES];
[textField setHidden:NO];
If it is hidden, the user can't interact with it or see it.
Upvotes: 3