ios - ActionSheet not working iPad -
I am using ActionSheet in my application. This works on my iPhone, but it is not on the iPad simulator.
This is my code:
IBAction function dialog (this: AnyObject) {go optionMenu = UIAlertController (title: zero: message: "Choose option", preferredStyle: (:, "delete" style: title .DEFAULT, handler: {(warning: UIAlertAction) - & gt; println ("Filtre deleted") .ActionSheet) go deleteAction = UIAlertAction) cancel cancelAction = UIAlertAction (title: "cancel", style: .cancel, handler: {(warning: UIAlertAction) -> zero in the println ("paused")} optionMenu. AddAction (deleteAc Tion) optionMenu.addAction (cancelAction) self.presentViewController (optionMenu, animated: true, perfection: zero)}and my error:
exception exception Due to 'nsgenic expiation' the app is terminated, the reason: 'Your application has been presented UIAlertController (style style) UIAlertControllerStyleActionSheet UIAlertController Model Presentation Style UIModalPresentationPopover with this style. You must provide location information for this popover via the popup presentation controller of the Warning Controller. You must either provide Source Weave and Source Rect or a Barton item. If this information is not known when you submit the information controller, you can make it available in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation. After presenting the Options menu since the UIPopoverPresentationController on the iPad, you will receive a source from the following:
For example, if you are presenting your options menu by tapping on the right navigation bar item. You can do something like this: Or you can set a view like this: Also keep in mind that if you change your ULTT Controller style to an alert rather than declare it, then you specify it Will not need to be I'm sure you should know this, but I want to help anyone coming to this page.
optionMenu.popoverPresentationController .barButtonItem = self.navigationItem.rightBarButtonItem self.presentViewController (optionMenu, animated: true, completion: zero)? <(You just need one of these 2) Code> optionMenu.popoverPresentationController .sourceView = yourView self .presentViewController (optionMenu, animated: true, perfection: zero)
Comments
Post a Comment