Home > database >  Image cannot show image in iOS 14 React Native
Image cannot show image in iOS 14 React Native

Time:11-23

Getting an issue local images not loading just showing blank in Ios

  <Image
            source={ImagePath.headerBgImage}
            style={{ width: '100%' }}
          />

CodePudding user response:

if I understand correctly, _currentFrame should be for animated image, so if it is still image, we can use the UIImage implementation to handle image rendering

react-native/Libraries/Image/RCTUIImageViewAnimated.m OR in pods React- RCTImage>RCTUIImageViewAnimated.m

Lines 283 to 289 in 1c634a9

 - (void)displayLayer:(CALayer *)layer 
 { 
   if (_currentFrame) { 
     layer.contentsScale = self.animatedImageScale; 
     layer.contents = (__bridge id)_currentFrame.CGImage; 
   } 
 } 

Replace above code with

if (_currentFrame) {
    layer.contentsScale = self.animatedImageScale;
    layer.contents = (__bridge id)_currentFrame.CGImage;
  } else {
    [super displayLayer:layer];
  }

CodePudding user response:

you should go to this file :

node_modules > react-native > Libraries > Images > RCTUIImageViewAnimated.m

and search word if (_currentFrame) then after find that add else like this :

 if (_currentFrame) {
    layer.contentsScale = self.animatedImageScale;
    layer.contents = (__bridge id)_currentFrame.CGImage;
  } else {
    [super displayLayer:layer];
  }

for more info see this link

  • Related