【发布时间】:2014-01-20 23:18:02
【问题描述】:
这显然是一个非常“幼稚”的问题。我知道UITextView 有一个Boolean editable 属性,(因为I'm not entirely illiterate)所以我的问题的答案似乎很简单。但是……
我像这样以编程方式创建一个 UITextView:
UITextView* input = [[UITextView alloc] initWithFrame: CGRectMake(0, 0, 100, 30)];
input.backgroundColor = [UIColor whiteColor];
input.editable = YES;
input.text = @"Type something here...";
[input setUserInteractionEnabled: YES];
....
[mainView addSubview: input];
但是,当我使用 Xcode 运行 iPhone 模拟器时,单击输入字段不会执行任何操作。我无法输入任何文字,虚拟键盘没有出现等等。
那么,我在这里做错了什么?为什么 UITextView 对象在 Xcode iPhone 模拟器中实际上是不可编辑的?
【问题讨论】:
-
你看到默认文本了吗?
-
这很奇怪......你看到文字和白色背景了吗?
-
是的,我看到了默认文本
-
mainView.userInteractionEnabled 了吗?
-
你在哪里添加 UITextView? ViewDidLoad?
标签: iphone objective-c xcode cocoa-touch