pathForResource:imgPath
2014-10-30 10:42
134 查看
+(id)createImageView:(CGRect)frame forPath:(NSString *)imgPath{
UIImageView *imageView = [[[UIImageView
alloc] init] autorelease];
imageView.frame = frame;
if (imgPath != nil) {
// UIImage *img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imgPath ofType:@"png"]];
UIImage *img = [UIImage
imageNamed:imgPath]; //CYY 发现上边那种方法只能读取到单倍图
imageView.image = img;
}
return imageView;
}
UIImageView *imageView = [[[UIImageView
alloc] init] autorelease];
imageView.frame = frame;
if (imgPath != nil) {
// UIImage *img = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:imgPath ofType:@"png"]];
UIImage *img = [UIImage
imageNamed:imgPath]; //CYY 发现上边那种方法只能读取到单倍图
imageView.image = img;
}
return imageView;
}
相关文章推荐
- pathForResource获取资源为nil的原因
- 根据文件名称获取资源文件路径 pathForResource
- javax.servlet.UnavailableException: Missing configuration resource for path
- NSBundle pathForResource取不到值如何解决?
- Maven:Description Resource Path Location Type Archive for required library 错误
- NSBundle pathForResource取不到值如何解决?
- cocos2d: fullPathForFilename: No file found at resource/Player.png. Possible missing file.
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- Description Resource Path Location Type Unparsed aapt error(s)! Check the Check the console for outp
- 关于[[NSBundle mainBundle] pathForResource:@"name"
- Missing configuration resource for path WebRoot/WEB-INF/struts-config.xml
- NSBundle pathForResource is NULL 取不到值
- iOS开发.[NSBundle mainBundle] 通过pathForResource返回路径为空.
- 安卓开发-问题集-Description Resource Path Location TypeUnparsed aapt error(s)! Check the console for output.
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- ios pathForResource函数返回空值
- NSBundle的pathForResource:ofType: 返回值为nil问题
- Ambiguous handler methods mapped for HTTP path 'http://localhost:8080/runyu/a/res/resource': {public
- 那些年我们遇到的坑(1)-Description Resource Path Location Type Archive for required library
- dataStage下编写javaStage报错TJStage::initialize: initializing Transformer for Java stage; resource path not found