2011-08-18 73 views
0

在three20的TTCatalog演示加載本地圖片,PhotoTest1Controller.m。還有是一些代碼如何three20的照片瀏覽器

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

文件網址(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];