UITableView泄漏? [英] UITableView leaking?

查看:88
本文介绍了UITableView泄漏?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableViewController,并且在viewDidLoadMethod中设置了一些属性,如下所示:

I have a UITableViewController and I set some properties in the viewDidLoadMethod like so:

- (void)viewDidLoad {
    [super viewDidLoad];

    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self.parentViewController.parentViewController action:@selector(dismissSettings)] autorelease];
    [self setTitle:@"Gabbai Settings"];

    //Set up the table 
    [self.tableView initWithFrame:self.tableView.frame style:UITableViewStyleGrouped];

    [self.tableView setRowHeight:65.0];
    [self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLineEtched];

    [self.tableView.backgroundView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"%@_settings", kTheme] ofType:@"png"]]]];


}

该应用程序显示一个UIScrollViewController和一个UIButton.按下按钮后,该应用程序将显示模式UINavigationController,并且该UINavigationController包含UITableViewController.

The app shows a UIScrollViewController and a UIButton. When the button is pressed, the app displays a modal UINavigationController and that UINavigationController contains a UITableViewController.

由于某些原因,当我显示UITableViewController时,Leaks报告了一些泄漏.但是,如果我注释掉//Set up the table之后的四行,一切都很好.

For some reason, Leaks reports some leakage when I show the UITableViewController. However, if I comment out the four lines after //Set up the table, everything is fine.

当取消注释四行时,泄漏"工具将显示以下内容:

When the four lines are uncommented, the Leaks instrument shows the following:

我不确定这是怎么回事,但这确实很烦人.我之前使用过相同的四行代码来自定义我的UITableViewController,这是一种新行为.

I'm not sure what is going on here, but it's really annoying. I've used the same four lines of code before to customize my UITableViewController and this is a new behavior.

有什么问题吗?

推荐答案

其他答案已指出,您的问题所在:

As has been pointed out by other answers, your problem is the line:

[self.tableView initWithFrame:self.tableView.frame style:UITableViewStyleGrouped];

它将创建一个新的UITableView对象,并且将修改self.tableView,这意味着该行完全没有意义.它只会造成您遇到的泄漏.删除它,就可以了.

It will create a new UITableView object and it will not modify self.tableView which means that line is totally pointless. It only creates the leak you are experiencing. Remove it and you should be fine.

这篇关于UITableView泄漏?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆