テーブルセルにスライダがあり、スライダをスライドさせると、そのセルが読み込まれて、セルに更新されたスライダ値が表示されます。テーブルセルの制約の変化をアニメーションにする
そして、ユーザーがスライダを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
を呼び出しています。しかし何も働かなかった。私は間違って何をしていますか?
私は再ロードの行がセルを再レイアウトし、アニメーション化されていないと推測します。 –
リロードテーブルコールを削除した場合、セルはスライダ値で更新されません!そこに何か回避策がありますか? –
セルで更新する必要があるものは何ですか?既に、sliderValueLabelなどの値を設定しているようです。 –