【发布时间】:2015-12-16 19:30:23
【问题描述】:
(1) 当我单击注释/固定时,我的动画效果很好。一个表格视图向上滑动。当我单击地图 (didDeselectAnnotationView) 时,tableview 会跳转到最终位置。 但是:当我单击一个单元格 (didSelectRowAtIndexPath) 时,动画会完美地向下滑动。
那么点击地图和点击tableViewCell有什么区别呢?它们都使用相同的功能。
(2) 还有一点: 在我的 tableView 中,我正在我的单元格中加载内容。当我尝试设置图像时,图像正确显示,但会终止所有动画。之后,每个向上/向下动画都在跳跃。
我很困惑。没有错误。我读到:当 animateWithDuration 有冲突或同时有 UI 动作时, animateWithDuration 会跳转。好的。但我该如何处理呢?有人有教程或一些一般提示吗?我不知道在哪里寻找我的错误。
我用 dispatch_asycn 尝试了一点,但没有任何效果。
感谢您的帮助,当英语不完美时,我们深表歉意:)
一些代码: (1) 动画:
func animateAllInformationAboutSingleDevice(up: Bool) {
// dispatch_async(dispatch_get_main_queue(), {
if up {
self.animationNSLayoutConstraint.constant += CGFloat(255)
} else {
self.animationNSLayoutConstraint.constant -= CGFloat(255)
}
UIView.animateWithDuration(Constants.animationTime, animations: { () -> Void in
self.tableViewController.layoutIfNeeded()
}, completion: {
(value: Bool) in
self.tableViewController.reloadData()
})
// })
}
删除功能:
func deleteAllInformationAboutVehicle(annotation: MKAnnotation) {
if let carAnnotation = annotation as? CarAnnotation {
if carAnnotation.itemId != "" {
setImageToDefaultImage()
//dispatch_async(dispatch_get_main_queue(), {
self.animateInformationScreen(false)
//})
}
}
}
(2) 在 tableView 中设置图像:
dispatch_async(dispatch_get_main_queue(), {
cell.carImage?.clipsToBounds = true
if let image = globalCurrentImageOfCar {
cell.carImage.image = GUITools.cropToBounds(image)
}
})
【问题讨论】:
标签: ios swift animation dispatch-async