iphone: relative paths to local file?
Using MontoTouch for .NET C# iPhone development. (though should not matter)
I开发者_高级运维n the iPhoneSimulator, I use UIImage.FromFile (@"images/Bahai.png"); to get the Bahai.png from the images folder.
However, when I run it in debug mode on my iTouch, the function returns a null.
Only if I put the image file in the root does it work in the iTouch.
Is there a different relative path I need to use?
Ian
Not sure if this will help, but in objective-C, I would load an image from the app bundle like this:
UIImage *image = [UIImaged imageNamed:@"Bahai.png"];
For other types of files, I would get the absolute path like this:
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"Bahai" ofType:@"png"];
精彩评论