美文网首页
imageWithContentsOfFile 读取nil

imageWithContentsOfFile 读取nil

作者: 不慌不忙 | 来源:发表于2017-12-14 09:50 被阅读12次

    1 . [UIImage imageNamed:name];  

    说明 : 有缓存的, 小图片和经常绘制的图片可以使用

    2.NSString*path = [[NSBundle mainBundle]pathForResource:filename ofType:type];

    UIImage*image = [UIImage imageWithContentsOfFile:path];

    说明 :没有缓存 , 使用一次后自动释放 , 对于一些大的图片 , 不经常绘制的图片 

    需要注意的的, 在使用imageWithContentsOfFile 这个方法的时候 , 发现图片没有显示 , 原来图片放在了Assets.xcassets 这个文件夹下 , 这是不可以的   

    解决办法: 建个文件夹 , 把这几张图 , 放在文件夹 , 拖到文件目录下  

    图片在这, imageWithContentsOfFile不能加载图片 把图片放到目录下 , imageWithContentsOfFile 可以加载

    相关文章

      网友评论

          本文标题:imageWithContentsOfFile 读取nil

          本文链接:https://www.haomeiwen.com/subject/yiuhwxtx.html