【问题标题】:Three20,TTLauncherItem set the image not in @"bundle://12.png"三20,TTLauncherItem设置图片不在@"bundle://12.png"
【发布时间】:2010-11-28 05:21:30
【问题描述】:

如果 TTLauncherItem 的图片不是来自@"bundle://12.png" 但如下所示,则不会显示为图片。

    [pageArray addObject:[[[TTLauncherItem alloc] initWithTitle:[titleArray objectAtIndex:(j+i*pageCount)]
                                                                  image:@"/Users/alex/Library/Application Support/iPhone Simulator/4.1/Applications/457F60DD-86EF-42E3-95F5-3BFC7C223987/Documents/magazine_covers/12.png"
                                                                    URL:@"tt://setUp" 
                                                              canDelete:NO] autorelease]];

不支持这种初始化吗?

【问题讨论】:

    标签: iphone three20 bundle ttlauncheritem


    【解决方案1】:

    我不确定文件系统上图像的直接 URL。 但是我在我的项目中使用图像作为 TTLauncherItem 图像执行以下操作:

    NSString* imageName  = @"my-sweet-icon.png";
    UIImage* thumbnail = [UIImage imageNamed:@"mySweetImage.png"]; 
    [[TTURLCache sharedCache] storeImage:thumbnail forURL:imageName]; 
    TTLauncherItem* item1 =  [[[TTLauncherItem alloc] initWithTitle:@"Title"
                                                            image:imageName  
                                                            URL:@"tt://url" canDelete:NO] autorelease];
    

    【讨论】:

    • imageName 在哪里定义以及如何定义?
    【解决方案2】:

    iOS 应用无法访问您的本地文件系统。使用 documents 关键字而不是 bundle。快速查看代码表明它也处理嵌套目录。

    @"documents://12.png"
    

    来源:Three20 source code

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-11-20
      • 1970-01-01
      • 1970-01-01
      • 2014-08-30
      • 1970-01-01
      • 1970-01-01
      • 2017-01-05
      • 2019-11-09
      相关资源
      最近更新 更多