在three20的TTCatalog演示中,PhotoTest1Controller.m。有一些代码
[[[MockPhoto alloc]
initWithURL:@"http://ww4.sinaimg.cn/bmiddle/6e8f23a5jw1dk7pylzs8ij.jpg"
smallURL:@"http://ww4.sinaimg.cn/thumbnail/6e8f23a5jw1dk7pylzs8ij.jpg"
size:CGSizeMake(320, 480)] autorelease],
我可以用本地路径替换这些URL。 我将图片放入应用程序包中。
答案 0 :(得分:0)
文件网址(file://
)应该可以正常使用。对于应用包中的图片,您可以使用-[NSBundle URLForResource:withExtension:]
:
NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"foo" withExtension:@"jpg"];
在iOS< 4.0您必须将基于路径的NSBundle
方法与+[NSURL fileURLWithPath:]
:
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"jpg"];
NSURL *imageURL = [NSURL fileURLWithPath:imagePath];