The first thing you need to do is set the UIAlertView delegate to do this add the UIAlertViewDelegate to your @interface so that it looks like
@interface myClass : super <UIAlertViewDelegate> // super could be anything like `UIViewController`, etc @end
and in @implementation you can add something like
@implementation myClass ........... Some code - (IBAction)someActionMethod:(id)sender { UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:nil message:@"Would you like to move on?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil]; [myAlertView show];
Remember to set a unique identifier in the storyboard. You can do this by going to your .storyboard and in the Identity Inspector (selecting the third one), you can set the Storyboard ID , this is what you will need to match with what is in instantiateViewControllerWithIdentifier , so in the above case it will be "secondViewController" It's simple.
Remember to close this view when you are done, you will need to use
[self dismissModalViewControllerAnimated:YES]
The above is really deprecated in iOS 6.0, but you can use
[self dismissModalViewControllerAnimated:YES completion:nil];
What does the same, except for it, adds a completion block to the end.
Hope this helps.
source share