【发布时间】:2015-05-06 15:02:30
【问题描述】:
我有一个带有拖放手势的视图。如果用户将视图拖放到另一个视图上,它将与该视图切换位置。在拖动UIPanGestureRecognizer 方法期间,我使用self.view.bringSubviewToFront(sender.view!) 将拖动的视图置于其他视图之上。
但是当我在最近删除的视图上调用bringSubviewToFront 时,该视图将立即移回其原始位置。如果你关闭 AutoLayout,它就可以正常工作。
func draggedViewHandler(sender:UIPanGestureRecognizer){
if(sender.state == .Began)
{
// If you drag the recently dropped view, this line will cause the view to jump back
// to its original position that was layout in Autolayout. If you turn off Autoview, it works fine.
self.view.bringSubviewToFront(sender.view!)
}
[additional code...]
}
这是 Swift 项目的完整工作副本。
【问题讨论】:
标签: ios swift uipangesturerecognizer