简体   繁体   中英

UIImageView in storyboard not showing on device and simulator

I have a UIImageView in storyboard. I have placed a .png image in .xcassests folder. I have correctly assigned the image name to the UIImageView which correctly shows in Xcode Storyboard. However when I run it on device/simulator, there is no image displayed. When I create the UIImageView in code then the image is displayed. My project code is in Objective-C

I have tried the following already

  1. Clean Xcode project
  2. Cleared Derived Data
  3. Closed Xcode and restarted device/simulator
  4. Deleted all images from .xcassets and reassigned

However none of the above has worked for me so far. Any suggestions are highly appreciated.

Well, it should work from what you implemented see. Xcode gets weird sometimes when it comes to referencing resources. I recommend removing the images, clean and build if possible remove the view controller and add again. See if it works.

Seems like there is no issue with the implementation part. Try adding clips to bounds to imageView

In case other people find this issue and struggle with it. The solution is simple. Select your XCAssets Container:

Xc 资产

Then select your target membership in the right hand panel

选择目标

Right click on the image in Xcode, go to File Inspector, and check the checkbox under "Target Membership". This might help.

Set the alpha of imageView as 1 instead of 0. 在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM