Iphone - UITextView内存泄漏

时间:2010-04-15 14:54:43

标签: iphone memory-leaks uitextview

当我使用UITextView时出现内存泄漏,但我不明白为什么:

  UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)];
  textView.text = @"Hello World";
  textView.editable = FALSE;
  [self.view addSubview:textView];
  [textView release];

有人可以帮助我吗? :S

2 个答案:

答案 0 :(得分:0)

当我使用泄漏仪器时,有泄漏。在扩展详细信息窗口中,对我的代码的最后一次调用是UITextView,它向我展示了UITextView的alloc和init上100%的泄漏。

以下是整个代码:

    UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)];

    [textView setTextColor:[UIColor blackColor]];

    [textView setFont:[UIFont systemFontOfSize:12]];
    // For internationalization.
    textView.text = NSLocalizedString(@"About-Description", @"");       

    textView.textAlignment = UITextAlignmentCenter;

    textView.editable = FALSE;
    [myView addSubview:textView];
    [textView release];

泄漏仪器是否可能出错并向我显示错误的线路?

答案 1 :(得分:0)

UITextView *textView = [[UITextView alloc] initWithFrame:CGRectMake(20, 160, 280, 150)] autorelease] 

可以帮到你