【发布时间】:2023-03-06 19:11:01
【问题描述】:
在 UITableView 中创建了 4x4 指标按钮。 我想按顺序选择按钮。
// 在单元格中为行索引创建按钮
for (int i = 0; i< [buttonArray count]; i++)
{
int buttonSpace = 10 * i + 10;
NSLog(@"ButtonPosition:%d",buttonSpace + (i * 50));
cell.Button = [[CustomButton alloc] initWithFrame:CGRectMake(buttonSpace + (i * 50),35, 50, 50)];
cell.Button.layer.cornerRadius = 25;
[cell.Button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
cell.Button.buttonIndex = i;
[cell.ScrollView addSubview:cell.Button];
cell.ScrollView.backgroundColor = [UIColor colorWithWhite:1.0 alpha:0.3];
}
rowIndexValue = indexPath.row;
// 视图控制器中的按钮操作。
-(void)buttonAction:(CustomButton *)sender
{
if (rowIndexValue) {
int counter = (int)[sender buttonIndex];
if (counter == incrementValue)
{
sender.backgroundColor = [UIColor redColor];
counter += 1;
incrementValue = counter;
}
else{
sender.selected = NO;
}
}
}
按顺序的按钮操作顺序,对于任何随机行。 用户选择第三行,但第三行中的选择行从第一个按钮开始,然后是第二个按钮,然后是第三个按钮,最后是第四个按钮。
4x4 - > 每行 UITableview 4 按钮的 4 行。单击按钮后,它将处于禁用模式
【问题讨论】:
-
到底是什么问题?
-
@Lion 我想在任何随机 UITableView 行中依次选择按钮。 4x4 4 行 for UITableview 每行有 4 个按钮。单击按钮后,它将处于禁用模式。
-
the button's in sequencally in any random UITableView row这条线是什么意思?
标签: ios objective-c uitableview uibutton