无法更改textview中的文本

时间:2011-04-21 04:38:32

标签: iphone objective-c ios ios4 uitextview

我遇到问题无法在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;
     /**/
}

感谢您的帮助:)

1 个答案:

答案 0 :(得分:1)

self.textDescription = [[[UITextView alloc] init] autorelease];

我认为这是问题所在。如果textDescriptionIBOutlet,则无需分配。{{1}}只需删除此分配。