objective c - iOS: Add a UIViewController above existing UIViewController -


i want make somekind of popup menu. have vc, , want vc animate , shown above first vc (second vc must bit smaller screen, first vc must visible).

i read apple documentation presenting vc that's not want, think. give me route move forward. must possible , think not hard do. thanks:)

first of all, it's possible present vc above vc. however, base on problem, think pushing uiview better present vc.

it want present vc1 above vc2, should make 1 root controller, 1 has present vc1 , present vc2 using root controller not vc1. see code below.

  //in view controller 1  vc1.m    appdelegate *app = [uiapplication sharedapplication];   uiviewcontroller *rootvc = app.window.rootviewcontroller;   [rootvc presentmodalviewcontroller:vc2 animate:no]; 

but, think, if want present viewcontrller's view , want view has own controller. can add controller child view controller current viewcontroller , present view on current viewcontroller. see this:

  // in vc1.m   [self addchildviewcontroller:vc2];   [self addsubview:vc2.view];// can animation here when vc2.view show 

see if help:)

how delete vc? i'm not sure trying do? if want delete , never use again, try relesing vc2. if want hide view , show again when menu button pushed. can try:

       //first if want hide        vc2.view.hidden = yes;        // , button set, can try        if(vc2 != nil)   // means vc2 created        {            if(vc2.view.hidden){vc2.view.hidden = no;}           else {vc.view.hidden = yes}        }else{           myviewc2 vc2 = [[myviewc2 alloc] init];           [self addchildviewcontroller:vc2];           [self addsubview:vc2.view];        }        //it's solution, can animation before hidden  

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -