gpt4 book ai didi

iphone - 如何在iphone sdk中设置类似的按钮标签和单元格标签

转载 作者:行者123 更新时间:2023-12-03 21:07:03 24 4
gpt4 key购买 nike

我有一个包含标签和按钮的表格。在该按钮上我生成了下拉列表。我想设置类似的单元格标签和按钮标签。因为据此我必须维持我的职能。供您引用,下图将为您提供想法

As per image, Suppose consider i am having 4 records means the "indexpath.row" for cell is 0-11 now i want to set my button tag and cell tag according following series 0 1 2 3 3 4 5 5 6 7 7 8 9 9 10 11 11  and so on b'cos data records are dynamic.

这是我在 CellForRowAtIndexPath 中的代码:-NSString *s; 变量=0;

if(indexPath.row<=2)
{
btn_click.tag=indexPath.row;

s =[dict valueForKey:[NSString stringWithFormat:@"%d",indexPath.row]];
}
else
{
if (indexPath.row%3==0)
{
Var=(NSInteger)(indexPath.row/3);

}
else
{
Var=Var+1;
}

if(indexPath.row%3==0 && Var==1)
{

btn_click.tag=indexPath.row;
s =[dict valueForKey:[NSString stringWithFormat:@"%d",indexPath.row]];

}

else
{
if (Var>1)
{
Var=1;
}
btn_click.tag=indexPath.row-Var;
s =[dict valueForKey:[NSString stringWithFormat:@"%d",indexPath.row-Var]];
}

}
NSLog(@"CELLTAGTag%d",btn_click.tag);

}

谢谢和问候,普里扬卡。

最佳答案

如果您想根据单元格行号为cellView和buttonView提供相同的标签号,您可以执行以下操作:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {


static NSString *CellIdentifier = @"CustomTableCell";
static NSString *CellNib = @"UserCustomTableCell";

UserCustomTableCell *cell = (UserCustomTableCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:CellNib owner:self options:nil];
cell = (UserCustomTableCell *)[nib objectAtIndex:0];
}

cell.myButton.tag = [indexPath.row];
cell.tag = [indexPath.row];

return cell;
}

关于iphone - 如何在iphone sdk中设置类似的按钮标签和单元格标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6138621/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com