【问题标题】:UIRefreshControl warns: CUICatalog: Invalid asset name or invalid scale factorUIRefreshControl 警告:CUICatalog:资产名称无效或比例因子无效
【发布时间】:2014-03-24 04:24:26
【问题描述】:

我在 viewDidLoad 中调用了这个函数

- (void)addRefreshControl { 
    refreshControl = [[UIRefreshControl alloc] init];
    [refreshControl setAttributedTitle:[[NSAttributedString alloc] initWithString:NSLocalizedString(@"Pull to refresh", nil)]];
    [refreshControl addTarget:self
                       action:@selector(refreshView)
             forControlEvents:UIControlEventValueChanged];

    [self setRefreshControl:refreshControl];
}

几乎每次我拉动刷新时,我都会在调试器中收到这条消息CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000的警告

它不会中断我的应用程序,但是,我想了解此消息的来源并避免它。

【问题讨论】:

    标签: ios ios7 uirefreshcontrol


    【解决方案1】:

    检查您是否有配对的@2x 图像。

    如果您使用情节提要,还要检查图像是否在图像字段中具有名称。

    我碰巧图片在情节提要中,但字段中的名称已被清除。

    【讨论】:

    • 是的,我有一个配对的@2x 图像,是的,图像的名称是相同的。经过长时间的搜索 + 反复试验,我发现你实际上需要 NSString 它的图像名称来自字典,就像我的那样。谢谢!
    【解决方案2】:

    所以基本上这与刷新控件无关,而是与初始化图像时使用的图像名称有关。 我曾经这样做过:

    [UIImage imageNamed:[someDictionary objectForKey:@"imageKey"]];
    

    但我真正需要做的是:

    [UIImage imageNamed:[NSString stringWithFormat:@"%@",[someDictionary objectForKey:@"imageKey"]]];
    

    因此,通过将其转换为 NSString,不再产生错误。当然,您需要有一个 @2x 配对图像,但即使您有这些,如果没有 NSString'ing 名称,您仍然会收到此错误。

    【讨论】:

      猜你喜欢
      • 2014-06-09
      • 2023-03-13
      • 2014-10-26
      • 2014-12-17
      • 2021-10-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多