2012-03-09 86 views
1

我的应用程序中有一个泄漏问题,我创建了一个autorelease对象的颜色,但通过intrument说有问题。drawRect方法导致泄漏

Malloc 1 04:12.221.102 32 UIKit +[UIColor allocWithZone:] 
Autorelease <null> 04:12.221.107 0 TurfNutritionTool_ver_5.1 -[UINavigationBar(CustomImage) drawRect:] 
Retain 2 04:12.221.125 0 UIKit -[UINavigationBar setTintColor:] 
Release 1 04:12.226.279 0 Foundation -[NSAutoreleasePool release] 
Retain 2 04:18.697.490 0 UIKit -[UINavigationButton setTintColor:] 
Retain 3 07:35.584.218 0 UIKit -[UINavigationBar setTintColor:] 
Release 2 07:35.584.225 0 TurfNutritionTool_ver_5.1 -[UINavigationBar(CustomImage) drawRect:] 
Release 1 08:30.378.434 0 UIKit -[UINavigationButton setTintColor:] 

这是我的代码

@implementation UINavigationBar (CustomImage) 

- (void)drawRect:(CGRect)rect { 

    UIImage *image = [UIImage imageNamed: @"toolbar_bkg.png"]; 
    [image drawInRect:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)]; 

    self.tintColor = [UIColor colorWithRed:0.913 green:0.725 blue:0.070 alpha:1.000]; //Yellow color 
} 
@end 

我希望你们发现我不能够发现到现在这个问题。

+0

你可以显示tintColor声明的代码吗? – 2012-03-09 12:32:27

+0

@PeterKelly'tintColor'是UINavigationBar的一个属性。 – Caleb 2012-03-09 12:42:41

+0

@Caleb当然是的,请参阅我的回答。 – 2012-03-09 12:49:05

回答

1

你可能没有什么可担心的。你不应该担心释放UIColor,因为你不拥有它。看看这个question

+0

非常感谢,它帮助我很多! – Retro 2012-03-09 13:46:58