gpt4 book ai didi

ios - drawRect 方法导致泄漏

转载 作者:行者123 更新时间:2023-11-29 13:39:11 26 4
gpt4 key购买 nike

我的应用程序中有一个泄漏问题,我正在创建一个颜色的自动释放对象,但通过仪器说问题存在。

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

我希望你们能找到我现在找不到的问题。

最佳答案

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

关于ios - drawRect 方法导致泄漏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9634066/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com