我有一个设置了原型单元的表格视图,当该视图首次加载正确的标签和滑块值时,将为每个单元正确填充该值。当我向下/向上滚动时,屏幕上看不见的单元似乎没有重新加载。它们具有空值。
我的数据来源是可变数组(localArray)
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LocalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
cell.labelOutlet.text = [[localArray objectAtIndex:[indexPath row]] localChannel];
cell.sliderOutlet.value = [[[localArray objectAtIndex:[indexPath row]] localPercentage] intValue];
return cell;
}
记录中
LOCAL CHANNEL: Webcast
LOCAL CHANNEL: The Stream
LOCAL CHANNEL: Email
LOCAL CHANNEL: Yammer
---Now scrolling
LOCAL CHANNEL: (null)
LOCAL CHANNEL: (null)
LOCAL CHANNEL: The Stream
尝试按以下说明更改您的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
LocalTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.labelOutlet.text = [[localArray objectAtIndex:[indexPath row]] localChannel];
cell.sliderOutlet.value = [[[localArray objectAtIndex:[indexPath row]] localPercentage] intValue];
return cell;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句