我已经动态创建了具有许多按钮的 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];
}