Access Asset Catalog pathForResource

后端 未结 6 1307
滥情空心
滥情空心 2020-11-27 17:46

It appears that:

[[NSBundle mainBundle] pathForResource:@\"name\" ofType:@\"png\"];

Does not return anything for assets that are inside the Ima

6条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-27 18:24

    Try using the image name as determined in the "Compile asset catalog" step. You'll find this in the build output. Be sure to expand the transcript - you should see something like this:

    /* com.apple.actool.compilation-results */
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-800-Portrait-736h@3x.png
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-800-667h@2x.png
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-700@2x.png
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-700-568h@2x.png
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-700-Landscape~ipad.png
    /path/to/Debug-iphonesimulator/Your.app/LaunchImage-700-Landscape@2x~ipad.png
    

    Tested using +[UIImage imageNamed:] with Xcode 6.1.1.

提交回复
热议问题