I am creating iPhone application by using storyboard. In this, how to create a popup on storyboard and how to add and dismiss this popup on viewcontroller.
Popup Sample Image:
i want to add popup in storyboard like this:
I am creating iPhone application by using storyboard. In this, how to create a popup on storyboard and how to add and dismiss this popup on viewcontroller.
Popup Sample Image:
i want to add popup in storyboard like this:
You might create it like this (don't forget to add <UIPopoverControllerDelegate>
to presenting view controller class)
UIStoryboard* storyboard = [UIStoryboard storyboardWithName : @"MainStoryboard" bundle : nil];
MyCustomPopoverContentVC* customContentViewController = [storyboard instantiateViewControllerWithIdentifier : @"MyCustomPopoverContentVC"];
// initialize popover controller with content view controller
UIPopoverController* popoverController = [[UIPopoverController alloc] initWithContentViewController: anyCustomViewController];
popoverController.delegate = self;
// change popoverContentSize here
CGRect contentFrame = CGRectMake(0.0, 0, 500.0, 500.0);
popoverController.popoverContentSize = contentFrame.size;
// present popover controller
[popoverController presentPopoverFromRect: _buttonRectForPopoverController inView: self.view permittedArrowDirections: UIPopoverArrowDirectionUp animated: YES];
and somewhere else in your presenting view controller class an example `UIPopoverControllerDelegate' method:
// refreshes the rect from where the popover is shown after interface orientations.
// this method is necessary and recommended by apple's documentation
- (void) popoverController : (UIPopoverController*) popoverController willRepositionPopoverToRect : (inout CGRect*) rect inView : (inout UIView*__autoreleasing*) view
{
*rect = _buttonRectForPopoverController;
}