Is it safe to present UIAlertController (alert style) on iPad without popover? - ios

In my app, I display a UIAlertController when the user taps on a button on the screen. I either use a UIAlertController or a UIAlertView, depending on the API availability (since my app supports both iOS 7 and 8).
I simply want to display an alert view to the user so I'm using the .Alert style for my UIAlertController.
When the user is on an iPad, is it safe to display the UIAlertController (Alert style) without configuring a popover?
I saw some tutorials online. From my understanding, if using a UIAlertController (Action Sheet style), I need to configure a popover or else the app will crash. I just want to know if it works the same way with an Alert style UIAlertController.
I did some test on my iPad and the app did not crash without the popover. But I want to make sure this is safe.

You never use a UIPopoverController with UIAlertView or UIAlertController (no matter its style).
iOS will internally use a popover on an iPad when the UIAlertController style is "action sheet" but you don't deal with that yourself.
So you have nothing to worry about. Use UIPopoverController as-is using the presentViewController:animated:completed: method no matter the device and you are fine.

Related

How to test if UIAlertView is shown on iOS 8?

I'm writing Unit tests for my app and there seems to be a problem with getting shown UIAlertView.
On iOS 7, this used to work:
UIAlertView* alertView = [NSClassFromString(#"_UIAlertManager") performSelector:#selector(topMostAlert)]
but this doesn't work on iOS 8.
Is there a way visible UIAlertView can be retrieved on iOS 8?
UIAlertView and UIActionSheet is combined in a class called UIAlertController in ios8. Kindly check the Apple Document
From Apple Doc
A UIAlertController object displays an alert message to the user. This
class replaces the UIActionSheet and UIAlertView classes for
displaying alerts. After configuring the alert controller with the
actions and style you want, present it using the
presentViewController:animated:completion: method.
Maybe it because iOS 8 use UIAlertController instead of UIAlertView.
Apple Developers Library "UIAlertController"

How can I keep UIActionSheet from being dismissed when background touched?

The default behavior for the UIActionSheet used to be that touching the background did not dismiss it, and in fact did nothing. But with iOS 7 touching the background is equivalent to pressing the cancelButton.
I'm modifying some software that needs to be kept to the iOS 6 behavior. How can I keep touches of the background from dismissing the action sheet?
You can achieve this by not using a cancel button.
Check this SO post:
UIActionSheet in iOS7 dismissing when user taps ANYWHERE on the screen on iPhone

iOS. Add to Passbook with Alert Dialog

Please, advise how I can create alert dialog, similar to Starbucks, shown in the image, when add to Apple Passbook.
I've tried to use PKAddPassesViewController, but failed, as it wasn't clear how to get alert dialog.
This looks like they are presenting a standard UIAlert before presenting the user with a PKAddPassesViewController.
It is not possible to directly replace the Add/Cancel buttons of the PKAddPassesViewController with an alert.

Emulating UIAlertView with voiceover: making the correct sound

I've decided to make a class that emulates the functionality of UIAlertView so that I can have a better API for callbacks and theme the alerts better. I add another window to the iOS main window to show the alert.
The problem is with voiceover. With the standard UIAlertView voiceover makes a special sound to indicate that there is an alert view on the screen.
I can get the standard voiceover screen change chirp by posting UIAccessibilityScreenChangedNotification but this is different from the Alert view's chirp.
I want this to feel like a UIAlertView for voiceover users. To do this i need to be able to programatically replicate its special chirp.
It's not ideal (you'd lose the theming for instance), but you could have your custom implementation detect if voiceover is enabled using UIAccessibilityIsVoiceOverRunning() and fall back to using a standard UIAlertView if it is.

Ipad ShareKit's UIActionsheet Issue

The Sharekit's initial UIActionsheet displays the items Email, Twitter and Facebook and Cancel on Iphone
However the same code ported to Ipad now the Cancel option is missing on its UIActionsheet.
why is that.
Are you using the action sheet in a popover? The standard dismiss interaction for a popover is touching outside of it. There is rarely a "cancel" button in a popover action sheet, and Apple's HIG recommends against it.

Resources