objective c - Navigate in uiviewcontroller iOS -


enter image description here

i have problem in memory management, when navigate specific uiviewcontroller

example:

i have 3 uiviewcontroller , use storyboard modal segue , stay in first , need go number 3 directly

i use code works fine, when need return 1 , if repeat code. receive memory warning , crash later.

this code:

go view 3 ->

uistoryboard *storybord = [uistoryboard storyboardwithname:@"main" bundle:nil]; uiviewcontroller * viewtree = [storybord instantiateviewcontrollerwithidentifier:@"three"]; [self presentviewcontroller:viewtree animated:yes completion:nil]; 

go view 1 ->

uistoryboard *storybord = [uistoryboard storyboardwithname:@"main" bundle:nil]; uiviewcontroller * viewone = [storybord instantiateviewcontrollerwithidentifier:@"one"]; [self presentviewcontroller:viewone animated:yes completion:nil]; 

you must presenting each view controller on each other, raising memory warning issue. present viewcontrollerthree use following code in viewcontrollerone

@implementation viewcontrollerone  - (ibaction) goto3 {        uistoryboard *storybord = [uistoryboard storyboardwithname:@"main" bundle:nil];       uiviewcontroller * viewtree = [storybord instantiateviewcontrollerwithidentifier:@"three"];       // brings third view controller.       [self presentviewcontroller:viewtree animated:yes completion:nil]; }  @end 

and go viewcontrollerone implement code in viewcontrollerthree

@implementation viewcontrollerthree  -(ibaction) backto1 {     // dismisses third view , brings first view controller.     [self dismissviewcontrolleranimated:yes completion:nil]; } 

Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -