使用[NSBundle MainBundle] pathForResources 拿不到 images.xcassets里面图片的路径

解决方案 »

  1.   

     NSBundle *bundle = [NSBundle mainBundle];
     NSString *path = [bundle pathForResource:imageName ofType:@"jpg"];
     UIImage *image = [UIImage imageWithContentsOfFile:path];*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM insertObject:atIndex:]: object cannot be nil'path一直返回(null),获取不到路径,哪位大神赐教一下,在线等!!!!!
      

  2.   

    要这样拿吗?images.xcassets里面的机制是什么样的呢?[NSBundle mainBundle]应该只能取到images.xcassets文件吧,就像一个你拖个压缩包进来,能这样获取压缩包里面的东西吗?我感觉是这个道理
      

  3.   

    images.xcassets 里的文件是不在ipa包的根目录下的,这里的图都不是以图片格式存储在程序包里.而是以文件形式储存在Assets.car文件中,所以是不存在文件目录的
      

  4.   

    images.xcassets里面的图片不都是直接使用的吗???还取它的路径干嘛
      

  5.   

    http://www.jianshu.com/p/5358f587af38      这篇上面写的应该是你想要的呢