This can be done easily just like when you are working with the standard ViewController.

Here is the sample code…

UIAlertView *alert = [[UIAlertView alloc] init];
[alert setTitle:@"My Title"];
[alert setMessage:@"My message"];
[alert setDelegate:self];
[alert addButtonWithTitle:@"OK"];
[alert addButtonWithTitle:@"Cancel"];
[alert show];
[alert release];

With this, you can detect which button was pressed by handling the alertView message like this.

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if (buttonIndex == 0)
{
// Yes, do something
}
else if (buttonIndex == 1)
{
// No
}
}

And when I do this in my game, I’ll pause the game first and resume when player pushed on the button. This can be done easily via sharedDirector as well.

[[Director sharedDirector] pause]; //Pause your game
[[Director sharedDirector] resume]; //Resume your game

Hope you enjoy!


Tagged with:
 

Facebook comments:

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Looking for something?

Use the form below to search the site:


Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...

reverse phone lookupTattoo DesignsSEO