加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

iphone – 访问外部包中的图像

发布时间:2020-12-14 17:49:18 所属栏目:百科 来源:网络整理
导读:我创建了一个名为applausible.bundle的软件包,我将软件包放在支持文件中.这是我的代码 NSBundle* myBundle;myBundle = [NSBundle bundleWithPath:@"/Library/applausible.bundle"];NSString *path = [myBundle pathForResource:@"splash.png" ofType:nil];[i
我创建了一个名为applausible.bundle的软件包,我将软件包放在支持文件中.这是我的代码

NSBundle* myBundle;
myBundle = [NSBundle bundleWithPath:@"/Library/applausible.bundle"];
NSString *path = [myBundle pathForResource:@"splash.png" ofType:nil];
[imageName setImage:[UIImage imageNamed:path]];

在这里,我无法在图像视图上显示图像.我尝试的另一种方法是在运行应用程序时使用xib将图像放在图像视图上.输出在控制台中就像这样
无法加载标识符为“com.xxxxxxx.ImageSample”的包中从nib引用的“splash_screen high resolution.png”图像.任何人都可以告诉我我在哪里犯了错误.最后我的目标是在外部捆绑的UIImageview上显示图像.

解决方法

这可能对你有所帮助.

NSString bundlePath = [[NSBundle mainBundle] pathForResource:@"applausible" ofType:@"Bundle"];
NSLog(@"Bundle path is %@",bundlePath);
NSBundle myBundle;
myBundle = [NSBundle bundleWithPath:bundlePath];
NSString *path = [myBundle pathForResource:@"splash_screen high resolution" ofType:@"png"];
UIImage *image=[[UIImage alloc]initWithContentsOfFile:path];
[imageName setImage:image];

请试一试.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读