iOS 5 View events order change - ios

Has anyone noticed that the order in which view events are fired in iOS 5 has changed? Using a Tab Bar switching from one view to another, the order in iOS 4 was: "viewWillDisappear" and then "viewWillAppear". In iOS 5 they are switched. Is it possible to use iOS 5 but have the previous order of events?

This is true.
Seems that the tab's viewDidLoad now gets called BEFORE the app delegate's didFinishLaunchingWithOptions.
I had the app launch initialising something and the viewDidLoad customising it. IOS 5 messed it up until I made the app init routine leave things alone if they had been setup.
I am guessing that you need to be prepared for this and either make your code check in each place that nothing is being undone or corrupted by the other.

Related

iOS app Killed and relaunched Showing my last VC

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.

How to be notified when UISplitViewController pops to master on iPhone mode?

I am using a UISplitViewController on iPhone 6 Plus, and I wish to be notified when in portrait mode the user goes back to the master view controller (i.e. when the split view acts like a navigation controller).
Moreover I wish to be notified in my UISplitViewDelegate the same way I am already notified when the user pushes the detail view controller (via the splitViewController:showDetailViewController:sender: callback)
Do you know the easiest (and cleanest) way to do it?
Thanks in advance.
In depends on what version of iOS we are trying to do that.
iOS 8.0~8.2 way your project should not be compatible with iOS 7 and will work ONLY iOS 8 and UP the best way is to use Size Classes (Trait collections) presented on WWDC 2014 and there was a video about this way, Session 214 "View Controller Advancements in iOS 8"
Briefly it now has a property
This property indicates if detail view is collapsed.(Session 214, Minutes 12:30 ->)
#property (getter=isCollapsed) BOOL collapsed;
A bit of KVO magic and you could have a callback of when detail view is available.
For old iOS 7 way you can detect current orientation of device and get current state of your detail.
Couple methods(rotation callbacks) you have:
willRotateToInterfaceOrientation:duration:
didRotateFromInterfaceOrientation:
interfaceOrientation
!!! BASED on Session 214(43:20) it is not recommended to use these methods with iOS 8 and UP because they are deprecated!!!
I'm not sure this 2 way are the best and easiest but they work properly as expected.And little advice to look WWDC videos, they are pretty helpful.
To be notified on MasterViewController's return, you'll have to create a delegate and set it to the DetailViewController, in performSegueWithIdentifier for example.
If so, when you will go back to master, the delegate will be fired.
Because show detail is adaptive, i.e. it either pushes on the master nav in compact width or sets as the split's secondary in regular width and you only want to know when the detail is popped, you'll instead need to use the master navigation controller's delegate which you can also set your app delegate to be.

Reset View hierarchy iOS

I'd like to add some code to the app delegate that resets the view hierarchy back to the beginning.
My app is basically a demonstration mockup, and I'd like EVERYTIME the app opens that it resets to the first view in the storyboard, and doesn't remember what page the user was on when they closed or 'minimized' the app.
I'm using iOS sdk 8.1, and Xcode 6.
Putting aside that it's actually quite bad user experience - it's very easy to do. You just need to specify that your app doesn't run in the background, and each time user closes app, next time - brand new copy will be launched.
Here is what you need to set in your project properties in Xcode:
If your'r info.plist Show raw keys/values option are enabled, the property is named UIApplicationExitsOnSuspend which you can get by right clicking on the empty space of info.plist properties table and selecting Add Row option as follows
and right after that you will be presented with following option,
where you can select second options which is Application does not run in the background.
Selecting the mentioned property and setting it to YES, the app opt out of background mode and it cycles between the not-running, inactive, and active states and never enters the background or suspended states and moved back to the not-running state. In other words, iOS will not preserved any states which allows the app to run as fresh on next launch.

iOS 8 viewDidAppear called before appWillBecomeActive?

I'm just experiencing something weird and it seems to be a change in iOS 8.
Previously(iOS7) when testing appWillBecomeActive was called before viewDidAppear. Is it so that in iOS 8 it is the other way around? what would then be a good workaround in order to make my app work on both iOS versions? is there some variable to test if viewDidAppear was called so I could run my setup functions of the view again?
EDIT: it actually seems quite random in iOS8. sometimes viewDidAppear is called before appWillBecomeActive. Sometimes it's the other way around...
appWillBecomeActive is a delegate located in your Application Delegate itself.. there's no guarantee that it will be called before any other UIViewController delegates (viewWillAppear,DidLoad,Init)
if you want to make any logic before loading of any other pages come alive.. you may want to use application:didFinishLaunchingWithOptions: and you may want to load the launching view by yourself or create a new delegate to detect that you finished the logic that you'll put in your application:didFinishLaunchingWithOptions: .

Application life cycle iOS

I having a problem with the application life in iOS programming. My application has the view controller that has been subclassed for drawing. Everything went fine till I decide that went the app go inactive (Press Home). I want it to load a new screen. I used notifications of applicationWillEnterForeground and a few others. What happens the drawing code fails when I try to get the UIGraphicsGetCurrentContext, it comes back as nil. I assume I am attempting to get the context before it is available. What is the proper event. I think I tried all but the right one.

Resources