我有两个UIViews,他们分别工作得很好。然而,一旦UIView下部重叠,UIView 2就不会在上部UIView 1覆盖的区域中注册?
UIView 1(品红色)重叠UIView 2(石灰)
UIView 1(品红色)接受向左/向右滑动。
UIView 2(lime)接受向上/向下滑动。
UIView 2(lime)显示没有重叠的UIView 1(品红色)
@IBOutlet weak var swipeAB: UIView!
@IBOutlet weak var swipeBC: UIView!
func calculateAB(sender:UISwipeGestureRecognizer) {
print("Swiped right, A to B")
}
func calculateBA(sender:UISwipeGestureRecognizer) {
print("Swipe left, B to A")
}
func calculateBC(sender:UISwipeGestureRecognizer) {
print("Swiped down, B to C")
}
func calculateCB(sender:UISwipeGestureRecognizer) {
print("Swipe up, C to B")
}
override func viewDidLoad() {
super.viewDidLoad()
moveAB.addTarget(self, action: #selector(GameViewController.calculateAB))
moveAB.direction = .Right
swipeAB.addGestureRecognizer(moveAB)
moveBA.addTarget(self, action: #selector(GameViewController.calculateBA))
moveBA.direction = .Left
swipeAB.addGestureRecognizer(moveBA)
moveBC.addTarget(self, action: #selector(GameViewController.calculateBC))
moveBC.direction = .Down
swipeBC.addGestureRecognizer(moveBC)
moveCB.addTarget(self, action: #selector(GameViewController.calculateCB))
moveCB.direction = .Up
swipeBC.addGestureRecognizer(moveCB)
}
答案 0 :(得分:1)
impression7vx,你当场了,谢谢!
我把两个重叠的UIViews分成了: