2016-08-17 4 views
0

2 개의 UIView가 있습니다. 개별적으로 잘 작동합니다. 그러나 UIView 2 하위 UIView overlapped, 위쪽 UIView 1 덮여있는 영역에 등록하지 않습니다?오버랩 UIViews가있는 스위프트 제스처 인식기

UIView의 1 (마젠타)의 UIView 겹치는 2 (석회)

enter image description here

UIView의 1 (마젠타)의 좌/우 와이프를 수용한다.

UIView 2 (석회)는 위/아래 슬쩍을 허용합니다. 중복 UIView의 1 (마젠타)없이 표시

UIView의 2 (석회) enter image description here

@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

슬쩍 감지? 그런 다음 오른쪽 상단 UIView 2 제스처를 것입니다, 나머지 1을 것이라고? 당신이하려고하는 것에 따라 이것을 할 수 있는지 확실하지 않습니다. – impression7vx

+0

이것은 트릭을 만들었습니다. 나는 답을 보여주는 사진을 올렸습니다. –

답변

0

impression7vx , 당신은 그 자리에 있었다, 감사합니다! 와이프를 오른쪽

  • UIView의 2 (황색) 좌 와이프를 검출하고 아래 와이프 할
  • UIView의 3 (라임 검출

    • UIView의 1 (마젠타)

      난에 가입 겹치는 두 UIViews 분할)는 3 UIViews로 2 UIViews를 분리 할 수 ​​최대

    Split into 3 UIView

  • +0

    대단하다, 다행스럽게 도울 수있었습니다! – impression7vx