help need for popToViewController
I got code as follow, but the popToViewController not working, I'm looping throught the ViewControllers list keep inside the navigationController, and base on the log, it show the correct ViewController found, but when i call the popToViewController, it just crash and show something like
"GNU gdb 6.3.50-20050815 (Apple version gdb-967) (xxxxx (date time)) Copyright 2004 etc etc"
Anybody got any idea about this? Really appreciate for any help!!! Thanks!!
Here is the sample code:
in View u1:
-(id)init {
return self = [super iniwithNibName: @"u1" bundle:nil];
}
-(IBAction)buttonGoU2: (id)sender {
UIViewController *u2 = [[UIViewController alloc] init];
[self navigationcontroller] pushViewController:u2];
[u2 release];
}
in View u2:
-(id)init {
return self = [super iniwithNibName: @"u2" bundle:nil];
}
-(IBAction)buttonGoU3: (id)sender {
UIViewController *u3 = [[UIViewController alloc] init];
[self navigationcontroller] pushViewController:u3];
[u3 release];
}
in View u3:
-(id)init {
return self = [super iniwithNibName: @"u3" bundle:nil];
}
-(IBAction)buttonBack: (id)sender {
NSArray *vList = [[self navigationController] viewControllers];
UIViewController *view;
for (int i=[vList count]-1; i>=0; --i) {
view = [vList objectAtIndex:i];
if ([view.nibName isEqualToString: @"u1"])
break;
}
[[self navigationController] popToViewController:view animated:YES];
[view release];
}
Last edited by applelim08; 01-18-2010 at 10:14 PM.
|