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将图像放在图像视图上.输出在控制台中就像这样 解决方法
这可能对你有所帮助.
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]; 请试一试. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |