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
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.
[textField setHidden:YES];
[textField setHidden:NO];
If it is hidden, the user can't interact with it or see it.
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
You use [abc setEnabled:NO]
to disallow the user to edit it, or setHidden
to completely hide it
精彩评论