2011-04-21 118 views
0

我有问题,无法在UITextView中设置新文本。我已经在界面生成器中将IBOutlet连接到textView。这里是我的代码无法更改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
self.textDescription = [[[UITextView alloc] init] autorelease]; 

我想这就是问题所在。如果textDescriptionIBOutlet,则不需要分配它。只要删除这个分配。

+0

谢谢。它的工作我会在2分钟内接受你的答案。 (弹出窗口说我可以在2分钟内接受答案) – crazyoxygen 2011-04-21 04:52:14

+0

ok gr8 :)。如果有用,请对答案进行投票 – visakh7 2011-04-21 04:54:50