Easy way to disable a UITextField?

前端 未结 5 1372
一向
一向 2020-11-29 08:01

Is there an easy way to disable a UITextField in code?

My app has 12 UITextField that are all turned on by default, but when a change is de

5条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-29 08:29

    This would be the simplest of all , when you multiple textfields too:

    in viewDidLoad:(set the delegate only for textfields which should not be editable.

    self.textfield.delegate=self;
    

    and insert this delegate function:

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{
    return NO;
    }
    

    Thats it!

提交回复
热议问题