0

in my app i take a picture which is saved to the camera roll. now when the picture has been saved, there's an alert which tells the user, that the image is successfully saved and a OK Button. Now i'd like to switch to another view Controller after pressing the OK Button in the alert box. how can this be done? thanks a lot.

its Xcode 4.3 / iOS 5.1

Max
  • 608
  • 1
  • 7
  • 23

1 Answers1

0

UIAlertViewDelegate is your answer for the problem. use the method

  • (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex

if you have only one button then for buttonIndex 0, you should push the other view. But make sure to set the delegate of the alertview to self and you shall be fine.

Farrukh Javeid
  • 634
  • 6
  • 25
  • thanks. but it does not really work. should be my mistake, but what did i wrong? http://pastebin.com/MqAna2DR – Max Jun 08 '12 at 11:04
  • i changed to if(buttonIndex == 0) but nothing happens as well – Max Jun 08 '12 at 11:11
  • What is the problem that you are facing? I am having hard time coming to nature of the question. – Farrukh Javeid Jun 08 '12 at 11:11
  • make sure you have not set the OK button to cancel or destroy button, otherwise there should be no problem. Check out this [link](http://getsetgames.com/2009/12/02/iphonedev-advent-tip-2-how-to-show-an-alert-with-uialertview/) to clarify yourself. – Farrukh Javeid Jun 08 '12 at 11:12
  • NSLOG does give me the right buttonIndex. but the ViewSwitcher does not work. DoneViewController *done = [[DoneViewController alloc] initWithNibName:@"DoneViewController" bundle:nil]; [self presentModalViewController:done animated:YES]; – Max Jun 08 '12 at 11:58
  • Try putting some breakpoints to check if the the control is being transferred to the alertview delegate and if the check is working or not. – Farrukh Javeid Jun 08 '12 at 12:13
  • the check is working. but the UIViewController "DoneViewController" does not appear. In the log there comes the message from the if{}-statement. – Max Jun 08 '12 at 20:13
  • I am not sure then what is the actual problem. Please make sure the button that you have set is in other buttons parameter in alert view allocation though. – Farrukh Javeid Jun 09 '12 at 15:48