Pregunta

I am trying to use UIAlertView to pull up a get ready title then pull it off the screen to let the player know the game is starting. How do I do this using UIAlertView?

¿Fue útil?

Solución

Try this Methods...

UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"Get Ready!" message:nil     delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];;

[alertView show];

[self performSelector:@selector(dismissReadyAlert:) withObject:alertView afterDelay:3.0];

-(void)dismissReadyAlert:(UIAlertView *)alertView
{
   [alertView dismissWithClickedButtonIndex:0 animated:NO];

   alertView.title = @"Your game is started!";

   [alertView show];

   [self performSelector:@selector(dismissStartAlert:) withObject:alertView afterDelay:2.0];
}

-(void)dismissStartAlert:(UIAlertView *)alertView
{
    [alertView dismissWithClickedButtonIndex:0 animated:YES];
}

Thanks!

Otros consejos

You need to keep a reference to the alert. Then just call this method:

[alert dismissWithClickedButtonIndex:0 animated:YES];

Declare UIAlertView Object in header file.

UIAlertView *alertReady;

Then Display alertview whenever you like to display and call one method to dismiss alertview

    alertReady = [[UIAlertView alloc] initWithTitle:@"Alert" message:@"Get Ready" delegate:nil cancelButtonTitle:nil otherButtonTitles: nil];
    [alertReady show];

    [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(hideAlertView) userInfo:nil repeats:NO];


-(void)hideAlertView
{
    [alertReady dismissWithClickedButtonIndex:0 animated:YES];
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top