iphone - How to pop from one view controller to another view controller -


using ios have 15 viewcontrollers want pop 1 viewcontroller view controller.

i using code:

secondviewcontroller *sec=[secondviewcontroller alloc]init]; [self.navigationcontroller popviewcontroller:sec animated:yes]; 

this shows error this viewcontroller not exist , using code:

nsarray *array = [self.navigationcontroller viewcontrollers]; [self.navigationcontroller poptoviewcontroller:[array objectatindex:1] animated:yes]; 

this code right pop thirdviewcontroller secondviewcontroller. happened when pop ninth(9th)viewcontroller fifth(5th)viewcontroller using code in ninth(9th)viewcontroller:

nsarray *array = [self.navigationcontroller viewcontrollers]; [self.navigationcontroller poptoviewcontroller:[array objectatindex:4] animated:yes]; 

it not pop ninth(9th)viewcontroller fifth(5th)viewcontroller apart pops ninth(9th)viewcontroller eight(8th)viewcontroller. don't know happened when use line:

nsarray *array = [self.navigationcontroller viewcontrollers]; nslog(@"array = %@",array); 

when use in ninth(9th)viewcontroller. nslog shows:

array=   first(1st)viewcontroller;            second(2nd)viewcontroller;          eight(8th)viewcontroller;          ninth(9th)viewcontroller; 

i don't know why 4 view controllers show. whenever using 15 view controllers. problem occurs in each view controller. instance if using pop form fifteenth(15th)viewcontroller fifth(5th)viewcontroller same problem manifests.

nsarray *array = [self.navigationcontroller viewcontrollers]; nslog(@"array = %@",array);  array=     first(1st)viewcontroller;              second(2nd)viewcontroller;            fourteenth(14th)viewcontroller;            fifteenth(15th)viewcontroller; 

i want count number of viewcontrollers , pop specific viewcontroller.

for (uiviewcontroller *controller in self.navigationcontroller.viewcontrollers)         {             if ([controller iskindofclass:[nameofyourviewcontrolleryouwanttonavigate class]])             {                 [self.navigationcontroller poptoviewcontroller:controller animated:yes];                  break;             }         } 

Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -