[[NSBundle mainBundle]pathForResource..取值为空
2017-09-28 21:06
1926 查看
最近遇到一个奇葩的问题,使用
这里提出一个解决方案仅供参考。
1、以实体文件的方式拖入图片文件夹
![](https://oscdn.geek-share.com/Uploads/Images/Content/202010/26/93d89a6ca01a4db792a32e25392948e6)
2、以实体文件的方式查找
如果以上方式还无法正确读取到文件可以继续下一步:
3、设置Bundle Resource, 选中工程->Build Phases->Copy Bundle Resources
![](https://oscdn.geek-share.com/Uploads/Images/Content/202010/26/0fa0f419f056fd7aa3576cabd8c6d6e6)
再次尝试应该就阔以啦。
[[NSBundle mainBundle]pathForResource:imageName ofType:@"png"];获取图片一直取不到图片,简直晕死,一直好用的方法突然不行了,只能另寻它法了。
这里提出一个解决方案仅供参考。
1、以实体文件的方式拖入图片文件夹
2、以实体文件的方式查找
NSString *path = [[NSBundle mainBundle]pathForResource:imageName ofType:@"png" inDirectory:@"images"];
如果以上方式还无法正确读取到文件可以继续下一步:
3、设置Bundle Resource, 选中工程->Build Phases->Copy Bundle Resources
再次尝试应该就阔以啦。
相关文章推荐
- [[NSBundle mainBundle]pathForResource..取值为空
- NSBundle mainBundle] pathForResource 返回nil的解决办法
- iOS [[NSBundle mainBundle] pathForResource:@"" ofType:@""]无法获取到文件
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- [[NSBundle mainBundle]pathForResource:@"name" ofType:@"type"] 获取不到本地文件
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- iOS开发中 [[NSBundle mainBundle] pathForResource: ofType:]路径为空的问题
- [[NSBundle mainBundle]pathForResource:@"XXX" ofType:@"db"]为nil的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name"
- iOS问题笔记-[[NSBundle mainBundle] pathForResource: ofType:]方法获取不到资源路径
- iOS开发 [NSBundle mainBundle] 通过pathForResource返回路径为空.
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- [NSBundle mainBundle] pathForResource: ofType: 获取不到数据
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- [[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"] 找不到对应的文件解决方法
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- NSBundle pathForResource取不到值问题
- NSBundle pathForResource取不到值问题