Reputation: 227
I have a home view ,when click on that it is going to another view again i am going to another view.when click on a button on that view a modalview will appear and then subsequently 3 more modal views when click on each modalview.when click on the final modalview an alert will appear and when click on that alert i want to show the root homeview.Is it possible ?
Upvotes: 0
Views: 379
Reputation: 61
int c=[self.navigationController.viewControllers count]-4;
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:c] animated:YES];
Upvotes: 0
Reputation: 20551
just give the delegate in .h file and after in delegate method of alertview write bellow code..
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 1) {
[self.navigationController popToRootViewControllerAnimated:YES];///this line is important..
}
else{
// do your action...
}
}
i hope this answer is useful to you..
:)
Upvotes: 0
Reputation: 38259
Sample Code given below:
UIAlertView *alert = [[[UIAlertView alloc] initWithTitle:@"Alert Message?" message:@"Error......" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK"] autorelease];
[alert show];
The implemention alertView's delegate functions is given below
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
//cancel clicked ...do your action
}
else if (buttonIndex == 1)
{
//OK clicked
[self.navigationController popToViewController animated:YES];
}
}
Upvotes: 0
Reputation: 1162
Display AlertView using given code snippet:
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:title message: @"Alert Message" delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil]; [alert show]; [alert release];
Delegate Method implementation :
}
Upvotes: 1