i am working on a navigation based application.On the top of the navigation bar there is a by default back button option.i have implemented a uialertview on click event of the back button.
-(IBAction)gotolevelcontroller:(id)sender//method is declared in leftbarbuttonitem's action selector
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Exit" message:@"Do You want to exit?" delegate:self cancelButtonTitle:@"OK"
otherButtonTitles:@"Cancel", nil];
alert.delegate = self;
[alert show];
[alert release];
}
- (void)alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
{
//go to previous screen of navigation control.
//what is code to go to previous screen
NSLog(@"ok");
}
else
{
//remain on same screen of navigation control
NSLog(@"cancel");
}
}
any suggestions?
Thanks
You are looking for the
poptoviewcontrollermethod of the navigation controller.