首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

从bundle资料包中加载数据

2012-11-04 
从bundle文件包中加载数据 //从文件包加载数据NSString *bundlePath[[NSBundle mainBundle]pathForResour

从bundle文件包中加载数据
//从文件包加载数据 NSString *bundlePath=[[NSBundle mainBundle]pathForResource:@"image" ofType:@"bundle"];//获取bundle路径,我的bundle包名为image.bundle if ([bundlePath length]>0) {//判断路径是否获取成功 //定义bundle,获取自定义包 NSBundle *imageBundle=[NSBundle bundleWithPath:bundlePath]; if (imageBundle!=nil) { NSString *path=[imageBundle pathForResource:@"610" ofType:@"jpg"inDirectory:@"images.bundles"]; if ([path length]>0) { UIImage *image=[UIImage imageWithContentsOfFile:path]; if (image!=nil) { NSLog(@"从文件包中加载成功!"); } else NSLog(@"保存失败"); } else NSLog(@"路径不存在"); } else NSLog(@"bundle不存在"); }

热点排行