下面是我收到错误的片段:
-(IBAction)rateButtonClick:(id)sender{
NSMutableArray *starImage = [[NSMutableArray alloc]initWithObjects:starImage1, starImage2, starImage3, starImage4, starImage5, nil];
NSArray *halfRateButton = [[NSArray alloc]initWithObjects:halfRateButton1, halfRateButton2, halfRateButton3, halfRateButton4, halfRateButton5, nil];
int buttonClicked = (((UIButton *)sender).tag);
int i;
for (i = 0; i < buttonClicked; i++) {
**starImage[buttonClicked].image = [UIImage imageNamed:@"rate.png"];**
}
if (lastButtonClicked != buttonClicked) {
**starImage[buttonClicked].image = [UIImage imageNamed:@"star-half-full.png"];**
}else
**starImage[buttonClicked].image = [UIImage imageNamed:@"rate.png"];**
lastButtonClicked = buttonClicked;
for (i = 0; i <= buttonClicked; i++) {
**halfRateButton[i].hidden = YES;**
}
}
错误出现在标记的行中。将它们更改为
**[starImage objectAtIndex:i].image = [UIImage imageNamed:@"rate.png"];**
行不通。我收到一个错误:
在类型 (id) 的对象上找不到图像属性。
在这里, satrImage1 到 starImage5 是UIImageViews
. halfRateButton1 到 halfRateButton5 是按钮。