我无法在 UITextView
中设置新文本。我已经在界面生成器中将 IBOutlet
链接到 textView
。这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
self.title = @"Detail";
[self setupTextView];
}
- (void) setupTextView
{
self.textDescription = [[[UITextView alloc] init] autorelease];
NSString *foo = @"blah blah blah";
textDescription.text = foo; //I try this and it didn't work
//here didn't work too.
//textDescription.text = [textDescription.text stringByAppendingString:foo];
/*Here is something for dynamic textview*/
CGRect frame;
frame = textDescription.frame;
frame.size.height = [textDescription contentSize].height;
textDescription.frame = frame;
/**/
}
感谢您的帮助:)
最佳答案
self.textDescription = [[[UITextView alloc] init] autorelease];
我认为这就是问题所在。如果 textDescription
是 IBOutlet
,则无需分配它。只需删除此分配即可。
关于iphone - 无法更改 TextView 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5739589/