【问题标题】:UIImage in Theos Tweak on SpringBoard?在 SpringBoard 上的 Theos Tweak 中的 UIImage?
【发布时间】:2014-01-19 15:14:35
【问题描述】:

大家好,在 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 上时,它只是保持空白

【问题讨论】:

  • 你试过[basePic setImage:[UIImage imageWithContentsOfFile:@"pic.png']吗?
  • NSLog(@"%@",[UIImage imageWithConentsOfFile:@"layout/private/var/stash/subject4stw/weatherspring/pic.png"]); 这是什么意思?
  • 在链接的答案中,imageWithContents**Of**File 强调大写 O 与小写 o,这不是您的代码存在的问题。
  • @nhgrif 感谢您的回答和呃...我应该在哪里看到输出?我试过 deviceconsole 但找不到它。
  • @santhu 这是一个调整,所以我必须保留那种类型的目录树

标签: ios objective-c uiimage theos cydia-substrate


【解决方案1】:

您需要指定图像在文件系统中出现的路径,而不是在项目目录中出现的路径。

而不是这个:

[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"]];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多