UIAlertController weird behaviour - ios

I am facing a weird issue with UIAlertController.
On approval/rejection of a ticket, an alert is presented like below
When alert first appears
If the screen gets locked on this page and we reopen the phone, then because of re-auth everytime app becomes active, we see the following screen.
when auth screen is presented over alert
If the pin is put now, and app opens, the alert control occupies a buggy position at the top like this.
when auth is done and alert screen appears
This is mainly because the auth screen was presented over alert control and everytime another control is presented over alert, this same bug re-appears.

Related

Apple TV - Menu button returns to wrong screen

I have an Apple TV app that starts out with a splash page. It plays a short video and does some setup networking. After these both finish I automatically transition the user to a Landing page for them to sign up for the service.
let langingPageVC = LandingPageViewController(nibName: nil, bundle: nil)
self.present(langingPageVC, animated: true, completion: {
print("Transferred to landing page")
})
The problem occurs when the user hits the menu button from this point. They are automatically taken back to the splash page, and the app just displays the static image it display while waiting for the networking to complete and stays there. The user can then press the menu button again and exit the app. If the user re-enters the app, they will be on this static image and not be able to do anything.
How can I make it so the app just goes to background directly from my landing page and doesn't go back to the Splash page? I know how to detect the menu press with a gesture recognizer, but there doesn't seem to be a call I can make that will background the application from that point.
I have tried removing the Splash page from its parent in the completion block and that didn't work. I saw something about setting the page as the keyWindow but I got a message in the log saying not to do that and that the system is supposed to handle it, and it also didn't work.
Any help is appreciated.
Two possible options:
Instead of presenting LandingPageViewController from SplashViewController, you could set LandingPageViewController as rootViewController. That way your splash will not be in your backstack of viewcontrollers.
Present SplashViewController in a separate window over LandingPageViewController. Once your video finishes you can dismiss the window.

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.

UIAlertViews, UIActionSheets and keyWindow problems

I created an iOS 7 passcode replica and I have this problem I can't seem to solve. I need the lock screen view to be on top of everything else, so the app is covered in iOS' multitasking view, so I add it directly to the keyWindow. Everything fine so far.
The problem arises if there's an alertView or actionSheet (will only mention alertViews in this post, to keep it simple) open when I have to display the lock screen. It has been answered several times that there are no references to alertViews in iOS 7, which is true, and the window in which they are displayed is _UIModalItemHostingWindow, which has 2 UIViews, indeed with no reference to the alertView.
This _UIModalItemHostingWindow also becomes the new keyWindow, so it's on top of everything else, but it can not be found in [UIApplication sharedApplication].windows meaning if I add the lock screen to my former keyWindow (the default keyWindow, if you will), it will be beneath the alertView and its dimmed background, so the user can't interact with the lock screen before dismissing the alertView. The other option is detailed a bit further below.
The lock screen works like this: on applicationDidEnterBackground it checks if the passcode is enabled; if it is enabled and the passcode duration is 0 (user selected to lock the app immediately), it adds the lock screen now, so it covers the app in the multitasking view. Now, the option I mentioned above is to add the alertView to this _UIModalItemHostingWindow window, but when returning to the app, the lock screen view is displayed with a 1+ second delay (even though I added it before I went to background!) and the app isn't covered by anything in the multitasking view. (Currently it's displayed in the wrong position too, if you go ahead and download it, that is fixed, but I didn't pushed the commit yet).
I tried hiding and removeFromSuperview this _UIModalItemHostingWindow, but when coming back to the app, the alertView animation still runs as if it was just fired. I suspect the delay mentioned above also happens due to how Apple handles alertViews when coming back to foreground.
I also tried creating a new window and to make that the new keyWindow, but same thing happens.
Here's a small discussion about this, covering all the stuff I tried, maybe I missed something in this post.
https://github.com/rolandleth/LTHPasscodeViewController/issues/16
Any ideas? Except creating manual references to every alertView and actionSheet inside my app, because I'm trying to find a fix for the passcode library, not my own apps; I can find dirty workarounds for that, no problem :)
Update: The window is _UIAlertOverlayWindow if an actionSheet is used instead of an alertView, but it behaves the same as far as I can tell.
The simplest solution is to have a lockscreen window instead of a lockscreen view.
Create a new UIWindow, set its frame to UIScreen bounds, put a simple rootViewController there that should handle rotation and display your "lock screen" views and set the windowLevel to UIWindowLevelAlert + 1.
Then set window's hidden to YES. Whenewer you want to show the lockscreen, just set hidden to NO.
I guess that adding a view to keyWindow also doesn't work when a popover/action sheet is displayed and also when a keyboard is displayed (keyboard has its own window on top of the key window).

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.

Resources