【发布时间】:2011-05-14 00:28:36
【问题描述】:
我一直在编写一个运行良好的代码,但我正在使用 Instruments 测试它是否有泄漏,并且遇到了 UIBarButtonContent 的泄漏,这是有问题的行。
UIButton *searchbutton = [UIButton buttonWithType:UIButtonTypeCustom];
[searchbutton setImage:[UIImage imageNamed:@"searchbutton.png"] forState:UIControlStateNormal];
[searchbutton addTarget:self action:@selector(search) forControlEvents:UIControlEventTouchUpInside];
[searchbutton setFrame:CGRectMake(0, 0, 29,29)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchbutton];
我应该在任何地方释放 searchButton 或 self.navigationItem.rightBarButtonItem。
一些帮助会很棒。
干杯
【问题讨论】:
标签: iphone memory-leaks ios4