NSBundle
bundle 是一个目录,包含了图片等资源
NSBundle *mainBundle = [NSBundle mainBundle];
去目录里面读取文件,然后用 UIImageView 展示:
通过 pathForResource 和 ofType 来获取图片
NSString *imagePath = [mainBundle pathForResource: @"***" ofType: @"png"];
用 UIImage initWIthContentsOfFile 传入一个 imagePath
UIImage *image = [[UIImage alloc] initWIthContentsOfFile: imagePath];
用 UIImageView initWIthImage
UIImageView *imageView = [[UIImageView alloc] initWithImage: image];
[self.view addSubview: imageView];
扩展:
https://www.jianshu.com/p/34cda6a121db
相关推荐
Apple NSBundle 使用说明文档
本文实例为大家区分NSBundle和NSURL,具体实现内容如下 在项目的工程中添加一个文件,本例程添加的是aa.txt,文件的内容为百度: www.baidu.com,现在要使用NSBundle和NSURL分别去获取内容,代码如下: // 读取文件...
对于许多朋友来说 NSBundle比较陌生 本文详细介绍了bundle的使用,相信你一看便知 有iphone开发 兴趣的朋友加我qq 1748283579 注明csdn 加上自己工作经验,少于半年iphone开发经验的勿扰。。
http://blog.csdn.net/duxinfeng2010/article/category/1155790 博客有详细介绍
例如,用图片代替:UIImage *normal_left = [[UIImage alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"left_normal" ofType:@"png"]]; UIImage *normal_right = [[UIImage alloc] ...
MCtCell * cell = [[[NSBundle mainBundle]loadNibNamed:@"Order" owner:self options:nil]objectAtIndex:0]; cell.title.text = @"区头"; MCtCell * cell1 = [[[NSBundle mainBundle]loadNibNamed:@...
return NSLocalizedString(rawValue, tableName: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "") } static func keys() -> [String] { return ["CAT", "DOG...
react-native-app-info 安装 $ npm install react-native-app-info --save $ rnpm link react-native-app-info 用法 var AppInfo = require('react-native-app-info'); console.log("应用版本号",AppInfo....
NSString *path = [[NSBundle mainBundle] pathForResource:name ofType:@"gif"]; NSData *gifData = [NSData dataWithContentsOfFile:path]; return [UIImage sd_imageWithGIFData:gifData]; } OC Extension ...
self.datePicker =[[[NSBundle mainBundle] loadNibNamed:@"DatePickerView" owner:self options:0] lastObject]; self.datePicker.frame =CGRectMake(0, self.view.frame.size.height-260, self.view.frame.size...
NSString * path = [[NSBundle mainBundle] pathForResource:@"LoveFree" ofType:@"plist"]; NSDictionary * contentDic = [NSDictionary dictionaryWithContentsOfFile:path]; //获取所有的键值 NSArray *...
NSArray *ary = [NSArray arrayWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"ProvinceCityDistrict" ofType:@"plist"]]; for (int i = 0; i ; i ++) { NSDictionary *province = ary[i]; for...
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"res5" ofType:@"jpg"]; NSData *emoticonData = [NSData dataWithContentsOfFile:filePath]; UIImage *thumbImage = [UIImage imageNamed:@...
ios开发的tom,全部素材和源代码,战士... NSString *path = [[NSBundle mainBundle] pathForResource:imageName ofType:nil]; UIImage *image = [UIImage imageWithContentsOfFile:path]; arrayM[i] = image; };
[queryItemArray addObject:[NSURLQueryItem queryItemWithName:@"version" value:[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleShortVersionString"]]]; [urlComponents setQueryItems:...
1:获取bundle Id信息:[[NSBundle mainBundle]bundleIdentifier]; 2:获取版本号:[[[NSBundle mainBundle]infoDictionary] objectForKey:@”CFBundleShortVersionString”]; 3:获取build号:[[[NSBundle ...
iOS界面app只可加载静态库,但server程序可以加载动态库。例子中含一简单实例,含Makefile。
*localHTMLPageFilePath = [[NSBundle mainBundle] pathForResource:localHTMLPageName ofType:@"html"]; NSURL *localHTMLPageFileURL = [NSURL fileURLWithPath:localHTMLPageFilePath]; [webView ...
如果你的对象是UIViewControler的子类,那么你必须调用- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil;方法去调用NIB文件初始化自身,即使那没有使用nib文件也会调用这个函数...