【发布时间】:2011-01-26 21:07:44
【问题描述】:
我正在创建一个 textField 并将其添加到这样的视图中:
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(/*blah blah */)];
textField.borderStyle = UITextBorderStyleRoundedRect;
textField.clearButtonMode = UITextFieldViewModeAlways;
[otherView addSubview:textField];
文本字段在otherView 中按预期呈现,但清除按钮永远不会呈现,无论我为 clearButton 分配什么值。有人知道这可能是什么原因吗?
【问题讨论】:
-
输入文字时看到clearButton了吗?
-
其实我刚刚又查了一下,我错了。当文本字段有值时,按钮就在那里。我想我假设“总是”的意思是“总是”,而它真正的意思是“当
.text != nil”。 -
有道理。如果没有文字,您希望清除什么?
标签: iphone objective-c cocoa-touch ios uikit