Browse Source

bugfix: YYAnimatedImageView.autoPlayAnimatedImage is NO when created from xib

ibireme 9 years ago
parent
commit
f64128caa6
1 changed files with 5 additions and 1 deletions
  1. 5 1
      YYImage/YYAnimatedImageView.m

+ 5 - 1
YYImage/YYAnimatedImageView.m

@@ -627,7 +627,11 @@ typedef NS_ENUM(NSUInteger, YYAnimatedImageType) {
     self = [super initWithCoder:aDecoder];
     self = [super initWithCoder:aDecoder];
     _runloopMode = [aDecoder decodeObjectForKey:@"runloopMode"];
     _runloopMode = [aDecoder decodeObjectForKey:@"runloopMode"];
     if (_runloopMode.length == 0) _runloopMode = NSRunLoopCommonModes;
     if (_runloopMode.length == 0) _runloopMode = NSRunLoopCommonModes;
-    _autoPlayAnimatedImage = [aDecoder decodeBoolForKey:@"autoPlayAnimatedImage"];
+    if ([aDecoder containsValueForKey:@"autoPlayAnimatedImage"]) {
+        _autoPlayAnimatedImage = [aDecoder decodeBoolForKey:@"autoPlayAnimatedImage"];
+    } else {
+        _autoPlayAnimatedImage = YES;
+    }
     
     
     UIImage *image = [aDecoder decodeObjectForKey:@"YYAnimatedImage"];
     UIImage *image = [aDecoder decodeObjectForKey:@"YYAnimatedImage"];
     UIImage *highlightedImage = [aDecoder decodeObjectForKey:@"YYHighlightedAnimatedImage"];
     UIImage *highlightedImage = [aDecoder decodeObjectForKey:@"YYHighlightedAnimatedImage"];