gpt4 book ai didi

iphone - TableView 中的 slider 问题

转载 作者:行者123 更新时间:2023-11-28 22:39:37 25 4
gpt4 key购买 nike

在我的应用中,我在表格 View 中添加了一个 slider ,即每一行都包含一个 slider ,它也可以正常工作。

但是当我滚动表格 View 时, slider 会重新加载,即每个显示我的起始位置而不是 slider 值。

//My code is as follow for slider in table cell:

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

NSString *CellIdentifier=[NSString stringWithFormat:@"CellIdentifier%d",indexPath.row];

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

if (cell == nil) {

cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier];

return cell;
}


UISlider* theSlider = [[[UISlider alloc] initWithFrame:CGRectMake(174,12,120,23)] autorelease];
theSlider.maximumValue=99;
theSlider.minimumValue=0;
[cell addSubview:theSlider];

return cell;
}

我该如何解决这个问题??

最佳答案

您必须将 slider 值存储在数组等中,并根据 cellforrowatindexpath 中的数组值设置 slider 值

关于iphone - TableView 中的 slider 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14933667/

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