开发者

iphone: relative paths to local file?

开发者 https://www.devze.com 2022-12-17 09:19 出处:网络
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

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号