1:设置代理
2:实现方法
NSString *grade = self.scoreBtn.titleLabel.text;
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"您的成绩" message:grade delegate:self cancelButtonTitle:@"不玩了" otherButtonTitles:@"新游戏", nil];
[self.view addSubview:alertView];
alertView.delegate = self;
[alertView show];
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
//不玩了,是0
//NSLog(@"buttonIndex is : %i",buttonIndex);
switch (buttonIndex) {
case 0:{
[MBProgressHUD showMessage:@"我在后台等你==||"];
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(3.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
exit(0);
// 移除HUD
[MBProgressHUD hideHUD];
// 提醒有没有新数据
//[MBProgressHUD showError:@"没有新数据"];
});
// [[UIApplication sharedApplication] performSelector:@selector(terminateWithSuccess)];
}break;
case 1:{
[self startNewGame];
}break;
default:
break;
}
}