How to test if UIAlertView is shown on iOS 8? - ios

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"

Related

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

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.

uialertview glossy look and feel

I have created a uialertview
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:#"Prohibited"
message:#"In-App Purchase is disabled, cannot make a purchase!"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:#"Ok", nil];
[alert show];
Which creates a dialog as below
But I need something like
How do I get this glossy look and feel ? Working in iOS 7.1, xocode 5.
My app uses UIWebView, UIViewController
It will look glossy as seen in that image on iOS 6 and lower OSs. iOS 7 is now flat.
Now if you wish to create your own UIAlertView by subclassing it. Theres a few tutorials that will teach you how to. but you'll need to create your own graphics and will cause a extra programming.
All your custom drawing will have to be inside the drawRect or overriding the various elements in the UIAlertView.
I would look at the way this github project does it's own customization to the UIAlertView
https://github.com/Sumi-Interactive/SIAlertView
For example:
The non glossy UI goes with IOS 7, I have an old app which has IOS 6 as the target version - it has the glossy alert views in an IOS 6 device (iPhone 3GS) but once running in an IOS 7 device it follows the new format., If it is really important you may want to simulate UIAlertviews using modal subviews .... [self presentViewController: mediaUI animated: YES completion:NULL]; or pop view controllers if coding for iPad.
Here is an old sample code : https://github.com/TomSwift/TSAlertView

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