set UITextField as non editable - Objective C

前端 未结 4 470
不知归路
不知归路 2020-12-16 16:49
    [Number.editable = NO];
    [Number resignFirstResponder];
    [Password.editable = NO];
    [Password resignFirstResponder];

I am getting the

4条回答
  •  爱一瞬间的悲伤
    2020-12-16 17:16

    Also, you can use the delegate methods.

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

    That would do the trick, I prefer this method over setting textField.enabled = YES when it's likely that the ability to edit will change during the lifecycle of the app.

提交回复
热议问题