2011-04-21 116 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