iphone - 无法更改 TextView 中的文本

标签 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;
     /**/
}

感谢您的帮助:)

最佳答案

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

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

关于iphone - 无法更改 TextView 中的文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5739589/

相关文章:

ios - 如何在 Swift 中实现 Realm.io 中的抽象实体

iphone - 当应用程序最小化时,performSelectorInBackground 不起作用

objective-c - 捏合缩放 - 无法在缩放时保持图像位置固定

php - 一个 SQL 行到一个 UILabel

ios - 导航栏重叠状态栏

iphone - 使用 NSFetchedResultsController 排序时如何忽略前缀 "A"和 "The"?

iphone - 调试 AFNetworking 内存使用峰值

ios - 动画自定义属性的值?

iphone - 如何以编程方式在 iPhone 中查找掉话?

ios - 文档共享面临的问题