简体   繁体   中英

How to disable and hide a UITextField

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM