This code is used to popToViewController to the index value of a particular Controller or popToViewController to the Home Screen of your Application.
-(IBAction)btnHome_Clicked:(id)sender{
NSInteger index = -1;
YourAppicationAppDelegate *appDelegate = (YourAppicationAppDelegate *)[[UIApplication sharedApplication]delegate];
UINavigationController *navigationController = [appDelegate navigationController];
NSArray* arr = [[NSArray alloc] initWithArray:navigationController.viewControllers];
for(int i=0 ; i<[arr count] ; i++)
{
if([[arr objectAtIndex:i] isKindOfClass:NSClassFromString(@"UIHomeViewController")])
{
index = i;
}
}
[self.navigationController popToViewController:[arr objectAtIndex:index] animated:YES];
}
there is great tutorial for the german developer community:
ReplyDeletehttp://bedifferently.wordpress.com/2012/01/15/xcode-4-tutorial-uinavigationcontroller/
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
ReplyDeleteYou could also replace iterating through the array with this. Substitute your index as needed.
Thanks Its working
ReplyDelete