سؤال

I call this function in my 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];
}

Nearly everytime I pull to refresh I'm getting warned with this message in the debugger CUICatalog: Invalid asset name supplied: (null), or invalid scale factor: 2.000000

It's not interrupting my app, however, I would like to understand where this message comes from and avoid it.

هل كانت مفيدة؟

المحلول 2

So basically this had nothing to do with the refreshcontrol but with the image name used while init'ing the image. I used to do this:

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

But what I really needed to do is this:

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

So by turning it into an NSString, the error isn't produced anymore. Sure you need to have a @2x paired image, but even if you have those, without NSString'ing the name, you'll still get this error.

نصائح أخرى

Check if you have the paired @2x image.

If you are with storyboard, also check if the image has the name in the image field.

Just happened to me that the image was in the storyboard but the name in the field was cleared.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top