UIActionSheet from Popover with iOS8 GM

Does anyone get this message trying to show a UIActionSheet from a popover?

Your application introduced UIAlertController () of the UIAlertControllerStyleActionSheet style. ModalPresentationStyle UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the popoverPresentationController alert controller. You must specify either sourceView, and sourceRect, or barButtonItem. If this information is not known when presenting the alert controller, you can provide it in the UIPopoverPresentationControllerDelegate -prepareForPopoverPresentation method.

Earlier to GM, I used some workaround to convert a UIActionSheet to a UIAlertController, and this works fine. However, it seems that Apple was trying to solve the problems with the UIActionSheet, and I did not want to use my workaround, but it seems that I have no choice ...

+42
ios ios8 uialertcontroller uipopovercontroller uiactionsheet
Sep 10 '14 at 7:42 on
source share
5 answers

To support iPad, enable this code:

alertView.popoverPresentationController?.sourceView = self.view alertView.popoverPresentationController?.sourceRect = self.view.bounds // this is the center of the screen currently but it can be any point in the view self.presentViewController(alertView, animated: true, completion: nil) 
+95
Dec 12 '14 at 9:52
source share

If you present an action sheet after the user makes a selection in a cell within a UITableView . I found that this works decently:

 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Directions" message:@"Select mode of transportation:" preferredStyle:UIAlertControllerStyleActionSheet]; alert.popoverPresentationController.sourceView = cell; alert.popoverPresentationController.sourceRect = cell.bounds; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil]; //... [self presentViewController:alert animated:YES completion:nil]; 
+11
Dec 6 '15 at 17:54
source share

You need to provide a popoverPresentationController to support iPad. In this case, you specify barButtonItem or sourceView . This other thread can help you: Swift UIAlertController - ActionSheet iPad iOS8 crash

+6
Sep 25 '14 at 21:31
source share

Actually this is something bad (I think) in Xcode for iPhone and iPad now.

  • On iPhone, the same code works fine, and you can see a warning message in the same place (always). But for the iPad, you need to determine the position of the warning window with alert.popoverPresentationController.sourceView = self.view; alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0 - 105, self.view.bounds.size.height / 2.0 + 70, 1.0, 1.0); alert.popoverPresentationController.sourceView = self.view; alert.popoverPresentationController.sourceRect = CGRectMake(self.view.bounds.size.width / 2.0 - 105, self.view.bounds.size.height / 2.0 + 70, 1.0, 1.0); 105 and 70 are approximate dimensional differences for the iPad portrait design due to the different anchor point.
  • On the iPhone, the UIAlertController design comes with “Modal View,” but unfortunately, if you use the same code for the iPad, it will not be “Modal View.” This means that you need to write additional code to disable touch in the design of the iPad. I think this is strange.
  • In the design of the iPad, you need to consider that the reference point is different. This is the bubble triangle point, not the upper left side of the AlertView.

These are strange things that I see. I think that there should be a standard, and if someone wants to get out of the standards, well, there may be other options.

+2
Dec 24 '15 at 15:57
source share

UIAlertController is only iOS8, and I need to support iOS7, I use it. I came across this kind of wizard in the “Master / Detail” layout on the iPad. I was able to get around this (not quite fix it) by lifting the UIActionSheet from the parent UISplitViewController using [actionSheet showInView:]. Good luck.

+1
Sep 10 '14 at 16:23
source share



All Articles