XCode 8 doesn't show images in storyboard

前端 未结 5 1611
伪装坚强ぢ
伪装坚强ぢ 2020-12-19 08:34

After updating xcode all images in the storyboard appeared as question marks (as it doesn\'t find them). I tried to remove/add them, cleared derived data but still all image

相关标签:
5条回答
  • 2020-12-19 09:07

    I had the same problem and I found out that it's because I don't have the image in the size that corresponds to the "View as" device selected in storyboard (bottom left).

    If you've selected a device that needs the @2x image (example: iPhone 6s) and you only have the @3x image (as I did) you will see the question mark. If you add the size for the image that corresponds to the device size that you are using for storyboard, the image will appear in your imageView.

    Basically, you want to have the image in all 3 sizes: @1x, @2x and @3x.

    0 讨论(0)
  • 2020-12-19 09:07

    Well I was in the same situation and came to know that xcode 8 storyboard removes frames and that is why images are not showing. Therefore you have to put appropriate constraints on uiimageviews and then you have to force constraints on by writing this code.

    UIImageView *uiv = [cell viewWithTag:100];
    [uiv setNeedsUpdateConstraints];
    [uiv setNeedsLayout];
    [uiv layoutIfNeeded];
    
    0 讨论(0)
  • 2020-12-19 09:27

    This is not an issue if you run your project and your image displays in simulator. Sometime is you change size classes then also this happens. for example if you are using multiple size class like wA,hA and wC,hr and you set constraints for any,any and compact,regular both and if you keep any,any selected in interfacebulder then it will show images properly but if you change it to compact,regular then it will shoe question mark because of simulated metrics's size. So, if it is not affecting output then it is not an issue!

    0 讨论(0)
  • 2020-12-19 09:32

    If you have only 3x images in your Assets that you want to work with and you have already Chosen the Initial Device View to some 2x device, then do the following:

    1. Open Storyboard file in Xcode 8.
    2. Go to File Inspector -> Interface Builder Document.
    3. Opens In -> Select Xcode 7.x
    4. Save & Close The Storyboard.
    5. Open storyboard again and Choose The Initial Device View To iPhone6s Plus.
    0 讨论(0)
  • 2020-12-19 09:33

    You have to use xcassets catalog for your images:

    1) Access Assets.xcassets

    2) Create new Image Set or choose from the list and update existing one

    3) Place your image variants in its @1x, @2x and @3x sizes:

    Call your image in your code like:

    let image = UIImage(named: "NewImageName")
    
    0 讨论(0)
提交回复
热议问题