addsubview does not invoke viewdidload ?

Discussion in 'iOS Programming' started by jagatnibas, May 28, 2009.

  1. jagatnibas macrumors regular

    Joined:
    Jul 28, 2008
    #1
    Hi All,

    I initialize a viewcontroller with initwithnibfile function and store that in a variable. similarly another view control.

    then i switch between adding and removing them as superview to window.

    but the thing is except for the first time, viewdidload function isnot getting called !. So when is exactly the view did load called ? only when we alloc and initwithnibfile ?

    regards
    jagat
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    viewDidLoad is called when the view loads. This will only happen once as once it's loaded it stays in memory.
     
  3. BlackWolf macrumors regular

    Joined:
    Apr 9, 2009
    #3
    Not 100% sure, but I think viewDidAppear will do what you want.
     
  4. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #4
    If you look at the utility app template project it does this. It switches the view controllers based on the frontside and backside. I'm pretty sure it calls viewDidAppear itself.
     

Share This Page