IOS 4.3 UINavigationBar tintColor Leaks

前端 未结 5 1211
暗喜
暗喜 2020-12-16 18:28

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: UIDeviceRGBC

5条回答
  •  臣服心动
    2020-12-16 19:19

    Ive had this issue before 4.2, i think colourWithRed:Green:blue allocates a new UIColor object which your responsible for managing.

    The solution is to create an instance for your tint colour and release it when your done with your navigation controller in viewDidUnload.

    - (void)viewWillAppear:(BOOL)animated
    {
        [super viewWillAppear:animated];
        tintBarColor = [UIColor   
                    colorWithRed:50.0/255   
                    green:134.0/255   
                    blue:187.0/255   
                    alpha:1];
        self.navigationController.navigationBar.tintColor = tintBarColor;
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        [tintBarColor release];
        // Relinquish ownership of anything that can be recreated in viewDidLoad or on     demand.
        // For example: self.myOutlet = nil;
    }
    

提交回复
热议问题