Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to move to next view controller after showing alertview

Tags:

xcode

iphone

I have iPhone and I want that when AlertView is shown and user presses OK button after that view should be changed but it is not happening.

  UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thank you" message:@"" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
  [alert show];
  [alert release];
  return;
  [self moveToView];

-(void)moveToView
{
    MainViewController*targetController=[[MainViewController alloc]init];
    [self.navigationController pushViewController:targetController animated:YES];
}
like image 927
user1495149 Avatar asked Nov 27 '22 17:11

user1495149


1 Answers

Please use UIAlertViewDelegate

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    // Code to move to next view
    [self moveToView];
}

Note: Implement the UIAlertViewDelegate in your interface Declaration. Also while declaring UIAlertView set the delegate to self.

Hope this helps you.

like image 138
Mathew Varghese Avatar answered Dec 19 '22 02:12

Mathew Varghese