테이블 셀에 슬라이더가 있으며 슬라이더를 슬라이드하면 해당 셀을 다시로드하여 셀의 업데이트 된 슬라이더 값을 표시합니다.테이블 셀의 애니메이션 제한 조건 변경
그리고 사용자가 슬라이더를 max로 이동 시켰을 때, 일부 애니메이션으로 셀의 요소의 너비 제한을 변경하고 싶습니다.
모든 것이 작동하지만 애니메이션을 볼 수 없습니다.
-(void)sliderValueChanged:(id)sender{
sliderValueChanged = YES;
UISlider *slider = (UISlider *)sender;
int sliderValue;
sliderValue = roundf(slider.value);
[slider setValue:sliderValue animated:YES];
NSIndexPath *indexPath = [self getIndexPathForView:slider];
MySliderCell *sliderCell = (MySliderCell *)[self tableView:self.tableView cellForRowAtIndexPath:indexPath];
sliderCell.sliderValueLabel.text = [NSString stringWithFormat:@"%d",sliderValue];
if(sliderValue == 7){
[sliderCell layoutIfNeeded];
sliderCell.radioButonWidth.constant = 40;
[UIView animateWithDuration:2.0
animations:^{
[sliderCell layoutIfNeeded];
}];
}else{
[sliderCell layoutIfNeeded];
sliderCell.radioButonWidth.constant = 0;
[UIView animateWithDuration:2.0
animations:^{
[sliderCell layoutIfNeeded];
}];
}
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];
DLog(@"slider value :%d change method called, indexpath is %@",sliderValue,indexPath);
}
또한 usig setNeedsUpdateConstraints
시도하고 self.tableView
대신 cell
에 layoutIfNeeded
를 호출했다. 그러나 아무 것도 효과가 없었습니다. 내가 도대체 뭘 잘못하고있는 겁니까 ?
다시로드 행이 셀을 다시 배치하고 애니메이션이 적용되지 않는다고 생각합니다. –
reload 테이블 호출을 제거하면 셀이 슬라이더 값으로 업데이트되지 않습니다! 주변에 어떤 문제가 있습니까? –
셀에서 업데이트해야 할 기타 항목이 있습니까? 이미 sliderValueLabel과 같은 값을 설정 한 것 같습니다. –