我想为 UITextView 设置默认文本。下面是我使用 text 属性进行初始化的代码,但它不起作用。我在这里想念什么?
@implementation DetailViewController
{
NSDictionary* inputFields;
}
- (id) init
{
self = [super init];
self.currentClaim = NULL;
inputFields = @{
// These fields must match AppDelegate's newFormData method
// TODO: Refactor so we don't need this dependency.
@"actionPlan" : [self createTextAreaForActionPlan:@"Action Plan" at:CGPointMake(20.0f, 1200.0f)],
// createTextAreaForActionPlan
};
return self;
}
- (UITextView*)createTextAreaForActionPlan:(NSString*)title at:(CGPoint)origin
{
float height = [self createTextLabel:title at:origin];
UITextView* textArea = [[UITextView alloc] initWithFrame:CGRectMake(origin.x, origin.y + height, 660.0f, 100.0f)];
[[textArea layer] setBorderWidth:1.0f];
[[textArea layer] setBorderColor:[[UIColor blackColor] CGColor]];
textArea.text =@"Default Text"; // this is the default text. how to show in UI TextView.
[textArea setFont:[UIFont systemFontOfSize:16.0f]];
[textArea setDelegate:self];
[[self view] addSubview:textArea];
return textArea;
}