yannickl / YLProgressBar

UIProgressView replacement with an highly and fully customizable animated progress bar in pure Core Graphics
http://yannickloriot.com/library/ios/ylprogressbar/
MIT License
1.28k stars 186 forks source link

A tip for "dealloc" method never be called #64

Open tatowilson opened 5 years ago

tatowilson commented 5 years ago

First of all, thank yannickl for this awesome project.

We imported the version 3.10.2 into our project, and found that the dealloc method was never called.

I found the _progressTargetTimer may never be invalid if the progress didn't reach the end. https://github.com/yannickl/YLProgressBar/blob/c7b29a65f2834a398214970b963a23d3d859956e/YLProgressBar/YLProgressBar.m#L326-L342

So I wrote this in the host view's dealloc method to invalidate the _progressTargetTimer:

_progressBar.progress = 0;

https://github.com/yannickl/YLProgressBar/blob/c7b29a65f2834a398214970b963a23d3d859956e/YLProgressBar/YLProgressBar.m#L227-L230 https://github.com/yannickl/YLProgressBar/blob/c7b29a65f2834a398214970b963a23d3d859956e/YLProgressBar/YLProgressBar.m#L287-L322

The dealloc method was called finally.