将UITextField设置为不可编辑 - 目标C. [英] set UITextField as non editable - Objective C

查看:102
本文介绍了将UITextField设置为不可编辑 - 目标C.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

我收到错误

请求成员'可编辑'的东西不是结构或联合

Request for member 'editable' in something not a structure or union

:S

谢谢

推荐答案

首先,如果你不是,则不需要 [...] 发送消息。

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

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

但这不是错误的原因。 .editable 属性仅为UITextView定义,而不是UITextField。你应该设置 UITextField的 .enabled 属性(注意UITextField是UIControl)。

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;
...

这篇关于将UITextField设置为不可编辑 - 目标C.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆