iOS: Dismiss presented ViewController which is an instance of specific Class - ios

I am using NYAlertViewController to display dialogs in my iOS-App. It can happen that I just opened a dialog when a background process tries to trigger another dialog. If this happens, the second dialog is not shown. I would like to close all other dialogs before opening a new one. How could I do this?
The Dialogs are shown with presentViewControllerAnimatedCompletion.
Maybe I can dismiss all ViewControllers that are instances of NYAlertViewController?
Any thoughts on that? Thanks!

Related

Hide the screenshot in multitasking switcher only in particular cases

Chase bank's iOS app is showing blank view hiding apps details when double tap the home button from the app. And when you login inside the app and touchID alert appears the apps view is not hidden by blank view.
So far I can hide app details by showing image loaded on applicationWillResignActive but it makes app hide it's details while touchID alert comes up.
I've checked similar questions on SO like this or this. Also here. But there is no answer to my question. How to replicate Chase bank's app behavior? How not to hide app details with touchID alert, but have them hidden when double tapped the home button?
I know it's an old question but couldn't find a valid answer to this exact question. So here's my solution.
steps:
create a instance variable for blocker view
init blocker view only once when it's necessary (I did it on applicationWillResignActive)
add blocker view as subview to the window at applicationDidEnterBackground
remove blocker view at applicationWillEnterForeground
The app delegate's applicationWillResignActive is the right place where you put a black or whatever view you want to show when the app is being moved to background. You need to add the desired UIView on Window object. Also you need to remove that view when the app becomes active again.

Delaying application while UIAlertView is active

I added an Alert view, asking for user input, at the start of my app. The app works fine without the Alert view. But with the code for the Alert view added, part of the UI is blacked out after hitting the 'ok' button on the alert.
I'm not well versed in ios, but is there a good way to delay the app from running until the Alert (text input) is completed (ok button pressed). This might avoid whatever is causing the screen to go black in one section. Apparently the app is executing while the alert is active, and the alert is affecting the UI. Basically, I am asking the user to input their phone number via an alert that will be used later in the app.
When alert view is shown on screen, getting back ground dimmed (reduced alpha) is a normal thing and is practiced by iOS.
However, if you feel some part of the code you want to run only on tap on OK button on alert, move that method call to OK button action handler.

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.

UIAlertView is not shown when returning from sleep mode in iOS app

My app must sometimes show an UIAlertView when the Home button or the locking button is pushed or when the notification center is shown.
I show the Alert from the applicationWillResignActive delegate's method and everything is ok when home button is pushed or when notificacion center is shown. But there is a problem if the button which is pushed is the locking button (on/off button).
In that case, the Alert is not shown when I return to the app (if I used the Home button it is there). I don't do anything else in other AppDelegate methods which are executed. Also, then, when I show a new Alert (any Alert in the app) the Alert which hasn't been shown when I returned is shown after I dismiss the new one.
Please, could anybody help me?
Thanks in advance.
THE EASY, GIVE ME REP ANSWER:
When the app is put into the background, the app is suspended. Part of this process is closing open alert views.
THE I ACTUALLY KNOW WHAT I'M TALKING ABOUT ANSWER:
The logic behind this is that when the user hits the home button when an alert is displayed, they might be going to look for information on how to answer the alert. However, when the sleep button is pressed, the user has stopped using the device altogether. Apple knows that if they unlock thier device again 3 hours later and see something like Confirm Deletion, they will have absolutely no idea what they were just doing and what to do now.
This is known to cause a serious condition known as what-in-the-world-am-I-supposed-to-do-now-itis. Symptoms of this condition include hitting the round button at the bottom of the screen and subsequently holding on your app icon until it jiggles. They then hit the little 'x' button. This is not good for developer's pockets.

iOS Reset/Restart Application from UIButton

I have a simple iOS app that I am developing that needs to be "restarted" or "reset" after a user performs a certain touch action and a "reset" button appears. The workflow of the app goes something like this:
User holds a certain area of the screen
User lets go of the screen and quickly touches another area
The time it took for them to let go and touch the next area is displayed in a UILabel.
A reset button appears in which the user presses to try again.
Steps 1-3 work perfectly, but currently the only way I have to "reset" the app is to exit with the home button, open the multi-tasking menu and manually close it and re-open it.
I know this has to be able to be done as I 've seen it in many apps. I just can't find much help with the developer docs on it.
Thanks!
You can kill the app with a call to abort(). There's no way to start it after you killed it, though.
Perhaps you can schedule a local notification before killing the app that prompts the user to open it again.
You should probably just create a method that resets all of your variables and then calls the methods that begin steps 1-3. To have the button appear, make a UIButton IBOutlet to attach to the reset button, and then hide it in viewWillAppear like this:
[myButton setHidden:true];
To then show the button later, use the same button but set the value to false instead of true.
You could try removing your view controller from the application window and releasing it then instantiating a new instance of that view controller and adding the new instance to the window as the root view controller.
Since I'm assuming your view controller is where most of your "setup" code for your app is occurring this should effectively reset the app without having to write a lot of extra code. In addition, having the ability to instantiate a new instance of your view controller class is kinda the point of having it to begin with.
You can sleep your application for specified time interval.
+ (void)sleepForTimeInterval:(NSTimeInterval)ti
or
+ (void)sleepUntilDate:(NSDate *)aDate
Methods is works for you
Please refer NSThread class Documentation

Resources