Xcode Image Catalogs: Image not showing in Interface Builder

≯℡__Kan透↙ 提交于 2019-12-07 10:47:55

问题


So, the artist sent me a Resources.xcassets folder that I simply dragged into the project. I then jumped to interface builder, added a new UIImageView, assigned an image name from the xcassets, and to my surprise, I couldn't see the images. It shows as a blue question mark.

Notice, that the IB autocomplete is working, and when I run the application, the assets actually show up! But not in interface builder, which makes laying the assets around virtually impossible, especially with the size to fit not working...

Bug reported: 15733387


回答1:


It seems I am at fault... I created a fresh new XIB, and made sure to select device family 'iPad', and the image is now showing up properly. I didn't think that was the problem because you cannot change the device family after creating the XIB! I looked everywhere for that options, but never found it... Seeing the raw XIB files, you can do this change manually, I guess (Notice where it says ".iPad"):

<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="4514" systemVersion="12F45" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.iPad.XIB" version="3.0" toolsVersion="4514" systemVersion="12F45" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none">

Yeah, I actually solved it, and the problem is super crazy. The artist had set all the assets as "iPad" assets, so the Contents.json file inside the *.imageset folder was assigning the "ipad" to the images I have. I opened the json file in sublime text, and changed the "ipad" to "universal", and BOOM. I had Xcode open on the side, and the image showed up almost instantly in IB!! Like, wth...



来源:https://stackoverflow.com/questions/20849745/xcode-image-catalogs-image-not-showing-in-interface-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!