UIImage in Theos Tweak on SpringBoard?

790 Views Asked by At

Hi people at StackOverflow

I can't get my image to show up on my SpringBoard

in my Tweak.xm SpringBoard is hooked, my UILabel shows up but my UIImage won't show up...

For the UIImage I tried to follow this question UIImage may not respond to imageWithContentsofFile

But I don't know what imageWithContents**Of**File meant stated in the answer so I'm still stuck with this code:

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

Can someone help me with this?

Also theos doesn't give any warnings or errors when compiling, it compiles and runs sucessfully

I tried

NSLog(@"%@",[UIImage imageWithContentsOfFile:@"/private/var/stash/subject4stw/weatherspring/pic.png"]);

and I got output, but when I try to let it show up on my SpringBoard it just stays empty

1

There are 1 best solutions below

0
On

You need to specify the path of the image as it appears in the filesystem, not as it appears in your project directory.

Instead of this:

[basePic setImage:[UIImage imageWithContentsOfFile:@"layout/private/var/stash/subject4stw/weatherspring/pic.png"]];

You would do something like this:

[basePic setImage:[UIImage imageWithContentsOfFile:@"/private/var/stash/subject4stw/weatherspring/pic.png"]];

However, I would not recommend putting any resources in this directory. As far as I know, the names of the folders in ./stash are auto-generated, and therefore may change with time or the device using the tweak. A constant path which you know is commonly used would suit better, so that line would now look something like this:

[basePic setImage:[UIImage imageWithContentsOfFile:@"/Library/Application Support/WeatherSpring/pic.png"]];