[self backgroundImages][[NSNumber numberWithInt:barMetrics]] = backgroundImage;
如何解决此警告?
答案 0 :(得分:2)
要摆脱警告使用
[NSNumber numberWithInteger:metrics]
或
[NSNumber numberWithInt:(int)metrics]
因为metrics是NSInteger而numberWithInt接受int而不是NSInteger。
但你真正想要的是
[self backgroundImages][(int)metrics];
答案 1 :(得分:1)
您尝试将NSNumber作为索引传递给您的数组,但您应该传递int:
[self backgroundImages][It should be an int number]
我认为backgroundImages是数组。 BarMetrics是一种UIBarMetrics类型,您无法将其作为int传递。
你可以这样做:
int i = -1;
if (barMetrics == UIBarMetricsDefault)
i = 0;
if (barMetrics == UIBarMetricsLandscapePhone)
i = 1;
// and so on....
[self backgroundImages][i]