ボタンに背景画像を設定する for ループがあります。基本的に、ボタンはさまざまなアイテムのサムネイル プレビューであり、静的に設定することはできませんが、コードはすべての UIView を実行するため警告を発しますが、適用されない setBackgroundImage を呼び出します。すべてのビューに。警告は苛立たしいものです。私はそれが不平を言っていることを理解しています。どうすればそれを取り除くことができますか? (警告を消したくありません、問題を解決したいです)
// For loop to set button images
for (UIView *subview in [self.view subviews]) // Loop through all subviews
{
// Look for the tagged buttons, only the 8 tagged buttons & within array bounds
if((subview.tag >= 1) && (subview.tag <= 8) && (subview.tag < totalBundles))
{
// Retrieve item in array at position matching button tag (array is 0 indexed)
NSDictionary *bundlesDataItem = [bundlesDataSource objectAtIndex:(subview.tag - 1)];
// Set button background to thumbnail of current bundle
NSString *picAddress = [NSString stringWithFormat:@"http://some.thing.com/data/images/%@/%@", [bundlesDataItem objectForKey:@"Nr"], [bundlesDataItem objectForKey:@"Thumb"]];
NSURL *picURL = [NSURL URLWithString:picAddress];
NSData *picData = [NSData dataWithContentsOfURL:picURL];
// Warning is generated here
[subview setBackgroundImage:[UIImage imageWithData:picData] forState:UIControlStateNormal];
}
}