How can i implement this popup menu in iphone app like a popover in ipad?
EDIT: This is the best at moment: https://github.com/runway20/PopoverView
How can i implement this popup menu in iphone app like a popover in ipad?
EDIT: This is the best at moment: https://github.com/runway20/PopoverView
Have a look at the iPhone UIPopoverController implementation: WEPopover
iOS 8 and later
Beginning with iOS 8, you can use
UIPopoverPresentationController
for iPhones in addition to iPads.Setup
UIBarButtonItem
to your main View Controller.UILabel
. If you want a whole menu, then just add a table view or list of buttons.show
, choosePresent as Popover
.popoverSegue
(or whatever string you called it in the code).Code
This is the code for the main view controller that has the bar button item in it.
Popover at an arbitrary anchor point
If you want to set the popover to appear somewhere besides a bar button item (on a
UIButton
for example) then you need to set thesourceView
andsourceRect
. See this answer for details.Further reading
The above example comes mostly from the first link.
You can check WYPopoverController: https://github.com/sammcewan/WYPopoverController
On iPhone you would generally use a UIActionSheet for a stack of buttons like that. It slides up from the bottom, rather than popping up next to the button, but that's the standard behavior on iPhone.
There is one that is even better than WEPopover. Developed by a company called 50pixels, it is called FPPopover.
You can download FPPopover at https://github.com/50pixels/FPPopover
You would have to manually instantiate a UIView using a custom background image or drawing with transparency, add some UIButtons (or other type of custom view) on top, and also somehow handle all touches outside that view.
Note that is is non-standard UI. An actionsheet would be more HIG compliant.