65

Actually, I would say that both iOS ViewControllers and Android Activities have their lifecycle methods. For example an equivalent of ViewController.viewDidLoad() is Activity.onCreate() ?

Else I still need to know the equivalent of the other :

  • OnStart()
  • OnRestart()
  • OnResume()
  • OnStop()
  • OnDestroy()
  • OnPause()
Jorgesys
  • 119,885
  • 23
  • 317
  • 256
Cool
  • 10,754
  • 14
  • 59
  • 81
  • possible duplicate of [Looking to understand the iOS UIViewController lifecycle](http://stackoverflow.com/questions/5562938/looking-to-understand-the-ios-uiviewcontroller-lifecycle) – Greg Mar 10 '15 at 16:28

1 Answers1

186

This is a comparison between the lifecycle of Android vs iOS:

enter image description here

  • Note: viewDidUnload is deprecated after iOS 6
Jorgesys
  • 119,885
  • 23
  • 317
  • 256
  • 4
    Thanks for your reply ! – Cool Mar 10 '15 at 16:36
  • 3
    Note: `viewDidUnload` is deprecated after iOS 6 – Ryan R Dec 06 '15 at 03:26
  • 17
    As far as I know, `viewWillAppear` and `viewDidAppear` are called when those views appear in the application window/context, not in the screen, it differs from onResume/onStart that are called every time the activity/fragment appears to the user. – Felipe Jun Mar 22 '16 at 15:07
  • A closer equivalent for `onCreate` might be both `loadView` + `viewDidLoad`. – Dean Kelly Apr 03 '16 at 16:46
  • More accurately onCreate is just loadView because you manually load the UI file and present it. After that point you are in `viewDidLoad` territory. – Allison Feb 18 '17 at 07:13
  • 6
    onStart() to ViewWillApear , onResume to ViewDidAppear, onPause to ViewWillDisapear, onStop to ViewDidDisapear, onRestart actually doesn't have equivalet in iOS. – Damyan Todorov Jun 02 '17 at 13:04
  • Be careful with onResume == ViewDidAppear, as onResume will be triggered every time Activity is resumed, but ViewController just the first time. – Pelanes Sep 26 '19 at 09:51
  • What about `awakeFromNib`? – iRohitBhatia Jun 08 '21 at 09:26