-
-
Notifications
You must be signed in to change notification settings - Fork 6k
Add animationImages support when using SDAnimatedImageView #3113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@kinarobin Thanks for your suggestion, I have updated the code. |
I wonder, what cause this issue ? We override the super startAnimating: and setImage:, and setAnimations also use the super implementation. If you use |
For example: SDAnimatedImageView *imageView = [SDAnimatedImageView alloc] initWithFrame:frame];
imageView.animationImages = animationImages;
[imageView startAnimating];
imageView.hidden = NO; There are two issues with the above code:
|
I see... This can be updated into the Unit Test (SDWebImage Tetsts), so that can ensure this will not be broken in later version. |
I've added the test cases for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have another way to solve this problem, by leaving all the control to UIKit, we don't touch.
Remove all the changes to SDAnimatedImageView
, only modify this method:
/// Check if it should be played
- (void)checkPlay
{
// Only handle for SDAnimatedImage, leave UIAnimatedImage or animatedImages for super implementation control
if (self.player && self.autoPlayAnimatedImage) {
[self updateShouldAnimate];
if (self.shouldAnimate) {
[self startAnimating];
} else {
[self stopAnimating];
}
}
}
I have tested this also match your behavior, but it's more suitable and maintainable. I think, SDAnimatedImageView should be a drop-in replacement for UIImageView. So if super class implementation do something, we should call their instead and only handle the case we added (That SDAnimatedImagePlayer
or SDAnimatedImage
), not assume current iOS's behavior.
For this issue, I think this autoPlayAnimatedImage
should only effect SDAnimatedImage
, we can update the code comment in header files about this.
See:
@dreampiggy Yes I see, it is better, I have updated the code, the test cases and the code comment in header files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now it's better :)
🍻 Yes, the previous treatment is not perfect, I should also deal with other properties properly, such as |
New Pull Request Checklist
I have read and understood the CONTRIBUTING guide
I have read the Documentation
I have searched for a similar pull request in the project and found none
I have updated this branch with the latest master to avoid conflicts (via merge from master or rebase)
I have added the required tests to prove the fix/feature I am adding
I have updated the documentation (if necessary)
I have run the tests and they pass
I have run the lint and it passes (
pod lib lint
)This merge request fixes / refers to the following issues: ...
Pull Request Description
Add
animationImages
support when usingSDAnimatedImageView
....