In IOS4.3 if I set
navigationBar.tintColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
I will get a memory leak: UIDeviceRGBColor leak
But if I use navigationBar.tintColor = [UIColor blackColor];
Everything is fine.
This never happened in ios4.2
I did some debug, and I found the [navigationBar.tintColor retainCount]
seems bigger if I use
[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];
Does anyone have the same issue?
This is the leak code:
In RootViewController:
- (void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:0];
[super viewWillAppear:animated];
}
In DetailViewController:
- (void)viewWillAppear:(BOOL)animated {
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0.9 green:0 blue:0 alpha:0];
[super viewWillAppear:animated];
}
If you go to DetailViewController, then popback to RootViewController, in the Instruments, you can see the UIDeviceRGBColor leak
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…