嗨,StackOverflow的人
我不能让我的形象出现在我的SpringBoard上
在我的Tweak.xm SpringBoard迷上,我的UILabel出现了,但我的UIImage没有出现.
对于UIImage,我试着遵循这个问题,UIImage may not respond to imageWithContentsofFile
但是我不知道imageWithContents**Of**File在答案中的意思,所以我仍然坚持这段代码:
[basePic setImage:[UIImage imageWithContentsOfFile:@"layout/private/var/stash/subject4stw/weatherspring/pic.png"]];
basePic.frame = CGRectMake(21.0,0.0,320.0,98.0);
[self.viewThing addSubview:basePic];
[basePic release];有人能帮我吗?
而且,在编译时,theos没有给出任何警告或错误,它成功地编译和运行
我试过了
NSLog(@"%@",[UIImage imageWithContentsOfFile:@"/private/var/stash/subject4stw/weatherspring/pic.png"]);我得到了输出,但是当我试图让它出现在我的SpringBoard上时,它就是空的。
发布于 2014-06-19 06:23:36
您需要在文件系统中指定映像的路径,而不是像在项目目录中那样指定它的路径。
而不是这样:
[basePic setImage:[UIImage imageWithContentsOfFile:@"layout/private/var/stash/subject4stw/weatherspring/pic.png"]];你会做这样的事:
[basePic setImage:[UIImage imageWithContentsOfFile:@"/private/var/stash/subject4stw/weatherspring/pic.png"]];但是,我不建议将任何资源放在这个目录中。据我所知,./stash中文件夹的名称是自动生成的,因此可能会随着时间或设备的调整而改变。您知道常用的常量路径更适合这种情况,因此这条线现在看起来如下所示:
[basePic setImage:[UIImage imageWithContentsOfFile:@"/Library/Application Support/WeatherSpring/pic.png"]];https://stackoverflow.com/questions/21218523
复制相似问题