iphone - TableView 中的 slider 问题

标签 iphone ios objective-c xcode uitableview

在我的应用中,我在表格 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/

相关文章:

iphone - 如何在 iPhone 中格式化 SQLite 日期?

ios - 如何使用 RxSwift 强制点击 UIBarButtonItem?

objective-c - header 变量的 obj-c 重复符号

ios - 不允许应用程序访问 UDID,也不允许使用 UIDevice 的 uniqueIdentifier 方法

objective-c - 有没有办法通过 UIActivityViewController 发送日历事件?

iPhone模拟器在3.0中不显示错误,但在2.0中显示

ios - 无法在 WebRTC 上设置 session 描述

ios - 嵌入 html5 的网站上的 MP4 视频无法在 iOS 上播放

iphone - 将 URL 图片添加到按钮点击

iphone - Facebook iOS SDK 3.0 教程中的 SIGABRT 错误