Repository: incubator-weex Updated Branches: refs/heads/0.16-dev a54bcb91d -> e766955fa
* [ios] fix image load event not fired when image download failed Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/29f5ecb7 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/29f5ecb7 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/29f5ecb7 Branch: refs/heads/0.16-dev Commit: 29f5ecb7a215116213b0d3c0217d6c509ac68890 Parents: e01d0e7 Author: acton393 <zhangxing610...@gmail.com> Authored: Wed Jul 26 18:04:32 2017 +0800 Committer: acton393 <zhangxing610...@gmail.com> Committed: Wed Jul 26 18:04:32 2017 +0800 ---------------------------------------------------------------------- .../WeexSDK/Sources/Component/WXImageComponent.m | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/29f5ecb7/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m ---------------------------------------------------------------------- diff --git a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m index b0cd45e..7faec0a 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXImageComponent.m @@ -317,6 +317,16 @@ static dispatch_queue_t WXImageUpdateQueue; dispatch_async(dispatch_get_main_queue(), ^{ __strong typeof(self) strongSelf = weakSelf; + if (strongSelf.imageLoadEvent) { + NSMutableDictionary *sizeDict = [NSMutableDictionary new]; + sizeDict[@"naturalWidth"] = @0; + sizeDict[@"naturalHeight"] = @0; + if (!error) { + sizeDict[@"naturalWidth"] = @(image.size.width * image.scale); + sizeDict[@"naturalHeight"] = @(image.size.height * image.scale); + } + [strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}]; + } if (error) { downloadFailedBlock(imageSrc, error); [strongSelf readyToRender]; @@ -336,13 +346,6 @@ static dispatch_queue_t WXImageUpdateQueue; strongSelf->_image = image; [strongSelf setNeedsDisplay]; } - - if (strongSelf.imageLoadEvent) { - NSMutableDictionary *sizeDict = [NSMutableDictionary new]; - sizeDict[@"naturalWidth"] = @(image.size.width * image.scale); - sizeDict[@"naturalHeight"] = @(image.size.height * image.scale); - [strongSelf fireEvent:@"load" params:@{ @"success": error? @false : @true,@"size":sizeDict}]; - } }); }]; });