Search code examples
iosuipopovercontrolleruisegmentedcontrol

How to display a popover when user touches and holds a segment in segmented control (iOS)


I need to display a popover with additional options when a user touches (and holds) a segment in UISegmentedControl. How do I:

  • detect the hold "gesture" on the segmented control.
  • Display the popover with additional options on top of the selected segment

Thanks!

note a related question is:iPad popover - How do you point to one segment in a segmented control?


Solution

    1. You would need to create a View with those "Options" you want manually. Or you could use third party library such as this

    2. Add a UILongPressGestureRecognizer to your UIView

    3. Get the position of the touch location and show the popover