小编nmn*_*mnm的帖子

IOS 4.3 UINavigationBar tintColor Leaks

在IOS4.3中,如果我设置

navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
Run Code Online (Sandbox Code Playgroud)

我会得到内存泄漏:UIDeviceRGBColor泄漏

但如果我使用navigationBar.tintColor = [UIColor blackColor]; 一切都很好.

这在ios4.2中从未发生过

我做了一些调试,[navigationBar.tintColor retainCount]如果我使用,我发现它看起来更大

[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
Run Code Online (Sandbox Code Playgroud)

有没有人有同样的问题?

这是泄漏代码:
在RootViewController中:

- (void)viewWillAppear:(BOOL)animated { 
        self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
        [super viewWillAppear:animated];
    } 
Run Code Online (Sandbox Code Playgroud)

在DetailViewController中:

- (void)viewWillAppear:(BOOL)animated {
        self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.9 green:0 blue:0 alpha:0];
        [super viewWillAppear:animated];
    } 
Run Code Online (Sandbox Code Playgroud)

如果你去DetailViewController,然后回弹到RootViewController,在Instruments中你可以看到UIDeviceRGBColor泄漏

iphone objective-c ios4

10
推荐指数
1
解决办法
3578
查看次数

标签 统计

ios4 ×1

iphone ×1

objective-c ×1