如何在Three20的照片浏览器中加载本地图片
在 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。 我将图片放入应用程序包中。
in three20's TTCatalog demo, PhotoTest1Controller.m .there's some code
[[[MockPhoto alloc]
initWithURL:@"http://ww4.sinaimg.cn/bmiddle/6e8f23a5jw1dk7pylzs8ij.jpg"
smallURL:@"http://ww4.sinaimg.cn/thumbnail/6e8f23a5jw1dk7pylzs8ij.jpg"
size:CGSizeMake(320, 480)] autorelease],
can i replace these URLs with local path.
i put the pictures into app's bundle.
文件 URL (
file://
) 应该可以正常工作。对于应用程序包中的图像,您可以使用-[NSBundle URLForResource:withExtension:]
:在 iOS 上
-[NSBundle URLForResource:withExtension:]
: 4.0 中,您必须将基于路径的NSBundle
方法与+[NSURL fileURLWithPath:]
结合起来:File URLs (
file://
) should work just fine. For images in your app bundle you can use-[NSBundle URLForResource:withExtension:]
:On iOS < 4.0 you must combine path-based
NSBundle
methods with+[NSURL fileURLWithPath:]
: