set UITextField as non editable - Objective C

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

I am getting the

4条回答
  •  悲&欢浪女
    2020-12-16 17:27

    Firstly, the [...] aren't needed if you're not sending a message.

    Number.editable = NO;
    [Number resignFirstResponder];
    Password.editable = NO;
    [Password resignFirstResponder];
    

    But this is not the cause of error. The .editable property is only defined for UITextView, not UITextField. You should set the .enabled property for a UITextField (note that a UITextField is a UIControl).

    Number.enabled = NO;
    ...
    

提交回复
热议问题