cxfeng1 closed pull request #1795: [iOS]sometime image size is so big when 
loading image
URL: https://github.com/apache/incubator-weex/pull/1795
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m 
b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
index 0c980985ef..ab4f63ced3 100644
--- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
+++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m
@@ -56,6 +56,7 @@ @interface WXImageComponent ()
     NSString * _imageSrc;
     pthread_mutex_t _imageSrcMutex;
     pthread_mutexattr_t _propertMutexAttr;
+    BOOL _shouldUpdateImage;
 }
 
 @property (atomic, strong) NSString *placeholdSrc;
@@ -80,6 +81,7 @@ @implementation WXImageComponent
 - (instancetype)initWithRef:(NSString *)ref type:(NSString *)type 
styles:(NSDictionary *)styles attributes:(NSDictionary *)attributes 
events:(NSArray *)events weexInstance:(WXSDKInstance *)weexInstance
 {
     if (self = [super initWithRef:ref type:type styles:styles 
attributes:attributes events:events weexInstance:weexInstance]) {
+        _shouldUpdateImage = NO;
         _async = YES;
         if (!WXImageUpdateQueue) {
             WXImageUpdateQueue = 
dispatch_queue_create("com.taobao.weex.ImageUpdateQueue", 
DISPATCH_QUEUE_SERIAL);
@@ -382,8 +384,21 @@ - (void)setImageSrc:(NSString*)src
     [self updateImage];
 }
 
+- (void)layoutDidFinish
+{
+    [super layoutDidFinish];
+    if (_shouldUpdateImage) {
+        [self updateImage];
+        _shouldUpdateImage = NO;
+    }
+}
+
 - (void)updateImage
 {
+    if (CGSizeEqualToSize(_view.frame.size, CGSizeZero)) {
+        _shouldUpdateImage = YES;
+        return;
+    }
     __weak typeof(self) weakSelf = self;
     if (_downloadImageWithURL && [[self imageLoader] 
respondsToSelector:@selector(setImageViewWithURL:url:placeholderImage:options:progress:completed:)])
 {
         NSString *newURL = nil;
@@ -600,6 +615,7 @@ - (void)cancelImage
     if ([[self imageLoader] 
respondsToSelector:@selector(cancelCurrentImageLoad:)]) {
         [[self imageLoader] cancelCurrentImageLoad:(UIImageView*)_view];
     }
+    _shouldUpdateImage = NO;
     [_imageOperation cancel];
     _imageOperation = nil;
     [_placeholderOperation cancel];


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to