0

I have a scrollView called sidebar. When I drag my finger on the screen close to the edge of my phone the sidebar pops op. Within the sidebar are UIViews that are subviews of sidebar. Additionally, each view is associated with a viewController. So each view is a subview and the corresponding controller is a childViewController of the subview. How do I recognize when my UILongPress has entered one of the views in my scrollView

rmaddy
  • 314,917
  • 42
  • 532
  • 579
  • This might be useful http://stackoverflow.com/questions/2788870/find-which-child-view-was-tapped-when-using-uitapgesturerecognizer. You can do this on the changed state of the long press GR. – danh Jul 08 '16 at 17:35
  • Thank you! The useful info is in let loc = gestureRecognizer.locationInView(view) and let subview = view?.hitTest(loc, withEvent: nil). The view variable can just be my sidebar. Here's another question. When I get a subView, how do I get it's corresponding viewController? –  Jul 08 '16 at 18:05
  • I also apparently get nil when I do the line et subview = view?.hitTest(loc, withEvent: nil). Any thoughts as to why –  Jul 08 '16 at 18:08
  • it will return nil if the location doesn't fall within the view's bounds. Make sure when you get location in view, that the view you pass is an ancestor of the views you will hitTest. – danh Jul 08 '16 at 21:02

0 Answers0