我动态创建了uiviews,它有很多按钮。它用于从每一行(uiview)中选择特定值(uibutton)。点击按钮时,我必须更改按钮图像(如突出显示)。现在我我是这样的,但订单不匹配。按钮没有在某些行中被选中。请检查下面的代码
for (int j=0; j<[viewTagAry count]; j++)
{
if ([[viewTagAry objectAtIndex:j] isEqualToString:[NSString stringWithFormat:@"%d",v]])
{
for (int i=0; i<[lastSelectedButtonAry count]; i++)
{
lastSelectedButton=[lastSelectedButtonAry objectAtIndex:i];
int tag=[[btnTagArray objectAtIndex:i] intValue];
UIImage *numImg=[UIImage imageNamed:[NSString stringWithFormat:@"%db.png",tag]];
[lastSelectedButton setBackgroundImage:numImg forState:UIControlStateNormal];
}
}
}
-(void)highlightButton:(id)sender{
UIButton *button = (UIButton *)[sender userInfo];
int t=button.tag+1;
UIImage *numImg=[UIImage imageNamed:[NSString stringWithFormat:@"%da.png",t]];
[button setBackgroundImage:numImg forState:UIControlStateNormal];
}