iOS app Killed and relaunched Showing my last VC - ios

Killing and relaunching iOS app, If I have View Controller A,B,C last visible View Controller was C. So now when I relaunch app i see View Controller C for 10 sec and then shows up Splash Screen. How can I avoid this.
Because of this first 10 sec User cant perform any event on app.

I think this is an operation system bug. But if you want to avoid this, you can try to add a splash screen image view before your app will go to background. You need to add your custom overlay view as subview to current window. Use this method to implement this feature: applicationDidEnterBackground. You can find more information about this feature here:
Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)

To force iOS to launch an app with its default viewcontroller or launch image, you need to call
UIApplication.shared.ignoreSnapshotOnNextApplicationLaunch()
where you implement state preservation.
Form the documentation : Documentation
Prevents the app from using the recent snapshot image during the next launch cycle.

Related

Launch Screen only showing once

I have used the LaunchScreen.storyboard file in my swift file to create a launch screen, however I only see the launch screen when I load the app onto my phone. After that, even when I kill the app I don't see the launchscreen again. I want it so that it shows every time the app is booted, so after it's been removed from the background like most other apps that exist. I there a setting that i need to toggle, or am I doing something wrong?
What you want can be achieved from the initial ViewController instead of Launch Screen.
Reason: Launch Screen timing is not fixed and can have a very short appearance if the app has recently been in the memory.
I would recommend you to use the welcome graphic/animation on the initial View Controller and move to the intended View Controller after a set timer by using a segue.
Edit: Additionally, in case of a graphic, you can put that on the Launch screen as well, then on the initial View Controller. That will get you continuity.
Hope this helps.

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.

Starts with specific scene when App launch from background iOS

I wonder how to launch the App from background with specific scene instead of always starts with launch screen or main.storyboard's initial ViewController.
For Example, if the user was viewing the profile scene and then make the app go to background from there, I would like to launch the same profile scene(without reloading or the profile pictures, bio, etc) the next time the user bring the app to the foreground.
Now the case is that the App always start with the launch screen and or the information that was loaded before went away.
How can I remember the specific scene when App enters background? By the way, I noticed this issue when I refractored the storyboard.
That's exactly what state restoration is for!
State restoration is a feature in iOS that lets a user return to their app in the exact state in which they left it – regardless of what’s happened behind the scenes.
You can enable it from your appDelegate by overriding application:shouldSaveApplicationState: and application:shouldRestoreApplicationState:
and having them returning true.
Then you will have to apply restorationIdentifier to your viewControllers (and yes, you can do it from the storyboard :) ). Doing so will allow your user to come back to the very screen / screen hierarchy they were when they last left...
You will however have to handle the logic the the data that need be displayed. In your viewController subclass, you can override encodeRestorableStateWithCoder: and decodeRestorableStateWithCoder: to store and then retrieve your data to display from the coder.
find the Apple doc here : https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/PreservingandRestoringState.html
And a Ray Wenderlich (love the man!) here : https://www.raywenderlich.com/117471/state-restoration-tutorial

Hide UI after resigning application [duplicate]

This question already has answers here:
Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot)
(8 answers)
Closed 8 years ago.
The question is the following:
My app can be protected with a password. When the user presses home button, application resigns inactive. After reopening it, app shows "enter password" screen. But before it shows up, the initial content screen is visible for a moment. Also if, after pressing home button, user enters preview mode (home button double pressed), preview shows content screen, not password screen.
So here are two questions:
How can I change UI (to password screen or to some placeholder) before application gets resigned, so that in preview mode user would see something other than the content screen.
How can I make application NOT show content screen for a moment (before password screen) when application becomes active again.
Would be thankful for any help.
From the iOS App Programming Guide
What to Do When Moving to the Background
Apps can use their applicationDidEnterBackground: method to prepare
for moving to the background state. When moving to the background, all
apps should do the following:
Prepare to have their picture taken. When the
applicationDidEnterBackground: method returns, the system takes a
picture of your app’s user interface and uses the resulting image for
transition animations. If any views in your interface contain
sensitive information, you should hide or modify those views before
the applicationDidEnterBackground: method returns.
So, in your applicationDidEnterBackground method you should hide your main view and present your 'login' view.
Update After a bit more research, it turns out you can't present a view controller - you can only affect the root window. I have tested the solution in this answer - Display a view or splash screen before applicationDidEnterBackground (to avoid active view screenshot) and it works - So you can create an image that shows your login screen and put that over the top of your UI.

IOS: turn off camera

In my app I use iphone camera, but the process is very low when I open it; then I want to start the process when I shows a splashscreen.
The problem is that when splashscreen ends I don't want to show camera.
Then while I show splashscreen I want to start process of camera and quit it before splashscreen disappear. Is it possible?
First up, Apple specifically advise against using splash screens in their Human Interface Guidelines document. I don't know if your app would get rejected for it, but best not to try.
Second, it sounds like you need to optimise the startup of your application and probably the first view controller. To do this, you need to put off loading/initialising everything you can until it's actually needed (known as "lazy initialisation). All code in applicationDidFinishLaunching: in your app delegate and your view controller's init method, loadView, viewDidLoad, viewWillAppear, viewDidAppear should be reviewed for stuff that could be done later.

Resources