【问题标题】:Can't change text in textview无法更改文本视图中的文本
【发布时间】:2011-04-21 04:38:32
【问题描述】:

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

感谢您的帮助:)

【问题讨论】:

    标签: iphone objective-c ios ios4 uitextview


    【解决方案1】:
    self.textDescription = [[[UITextView alloc] init] autorelease];
    

    我认为这是问题所在。如果textDescriptionIBOutlet,则不需要分配它。只需删除此分配即可。

    【讨论】:

    • 谢谢你。我会在 2 分钟内接受你的回答。 (弹窗说我可以在2分钟内接受ans。)
    猜你喜欢
    • 1970-01-01
    • 2012-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-19
    • 1970-01-01
    • 2014-03-09
    • 1970-01-01
    相关资源
    最近更新 更多