【发布时间】:2017-08-16 15:31:47
【问题描述】:
我正在尝试在选择 row 0 时旋转 UIImage 视图。在选择该部分需要重新加载以添加另外两个单元格。这是动画无法正常工作的地方。 imageview 只是转换到新位置而不执行动画。
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let cell = tableView.cellForRow(at: indexPath) as! CustomTableViewCell
if indexPath.row == 0 {
print(cell)
}
if displayCell {
UIView.animate(withDuration:0.3, animations: {
cell.rotateButtonImageView.transform = CGAffineTransform(rotationAngle: CGFloat(0))
})
if indexPath.row != 0 {
swap(&indexArr[indexPath.row], &indexArr[0])
print(indexArr)
}
} else {
UIView.animate(withDuration: 0.3, animations: {
cell.rotateButtonImageView.transform = CGAffineTransform(rotationAngle: (180.0 * .pi) / 180.0)
})
}
displayCell = !displayCell
tableView.reloadSections(IndexSet(integersIn: 0...0), with: .none)
}
另外,第 0 行的特定单元格的内容也需要更新。 这是一个sample 项目:
【问题讨论】:
-
究竟是什么原因无法正常工作?
-
我已经更新了问题
标签: ios swift uitableview uiimageview cgaffinetransform