【问题标题】:How to load a local picture in three20's Photo Browser如何在three20的图片浏览器中加载本地图片
【发布时间】:2011-08-18 13:15:05
【问题描述】:

在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。 我将图片放入应用程序包中。

【问题讨论】:

    标签: ios cocoa-touch ipad three20


    【解决方案1】:

    文件 URL (file://) 应该可以正常工作。对于 app bundle 中的图片,您可以使用 -[NSBundle URLForResource:withExtension:]:

    NSURL *imageURL = [[NSBundle mainBundle] URLForResource:@"foo" withExtension:@"jpg"];
    

    在 iOS NSBundle 方法与 +[NSURL fileURLWithPath:] 结合起来:

    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"foo" ofType:@"jpg"];
    NSURL *imageURL = [NSURL fileURLWithPath:imagePath];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-02-02
      • 2014-11-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多