我有 6 个 UIButtons 已在以下代码中生成:
int count = 0;
for (int i= 0; count<6; i++) {
for (int j=0; j<1&&count<6; j++) {
followbutn = [UIButton buttonWithType:UIButtonTypeCustom];
followbutn.frame = CGRectMake(20, i*44+53, 280, 40);
[followbutn setTitle:[followuparray objectAtIndex:count] forState:UIControlStateNormal];
[followbutn addTarget:self action:@selector(followaction:) forControlEvents:UIControlEventTouchUpInside];
[followbutn setImage:[UIImage imageNamed:@"checkbox_unchecked.png"] forState:UIControlStateNormal];
followbutn.tag = count;
[self.view addSubview:followbutn];
}
count++;
}
-(void)followaction:(id)sender
{
UIButton *button = (UIButton *)sender;
NSLog(@"%d",button.tag);
[followbutn viewWithTag:button.tag];
[followbutn setImage:[UIImage imageNamed:@"checkbox_checked.png"] forState:UIControlStateNormal];
}
当我单击任何按钮时,必须检查该特定按钮,而不得检查其他按钮。当我单击任何按钮时,只有带有最后一个标签的按钮会签入。
有人可以确定问题吗?