我正在尝试使用UIAlertView来获取准备好的标题,然后将其从屏幕上拉下来让玩家知道游戏正在启动。我如何使用UIAlertView做到这一点?
答案 0 :(得分:1)
试试这个方法...
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];
}
谢谢!
答案 1 :(得分:0)
您需要保留对警报的引用。然后只需调用此方法:
[alert dismissWithClickedButtonIndex:0 animated:YES];
答案 2 :(得分:0)
在标题文件中声明 UIAlertView 对象。
UIAlertView *alertReady;
然后,只要您想显示并调用一种方法来关闭alertview
,就会显示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];
}