Ios8 iOS 8 UIAlertView未显示按钮

Ios8 iOS 8 UIAlertView未显示按钮,ios8,uialertview,uialertcontroller,Ios8,Uialertview,Uialertcontroller,使用iOS 7.1中的UIAlertView在我的应用程序中显示一些警报在iOS 8中工作得非常完美警报会出现,但没有取消、确定和其他按钮。。。这会导致用户无法关闭警报,从而卡在该屏幕上,不得不关闭应用程序 我尝试为iOS UIAlertController 8实现UIAlertView和以前的版本,请参见下面的代码: if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) { UIAlert

使用iOS 7.1中的UIAlertView在我的应用程序中显示一些警报在iOS 8中工作得非常完美警报会出现,但没有取消、确定和其他按钮。。。这会导致用户无法关闭警报,从而卡在该屏幕上,不得不关闭应用程序

我尝试为iOS UIAlertController 8实现UIAlertView和以前的版本,请参见下面的代码:

if ([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) {
            UIAlertView *alerta = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"s000xS2", @"Alerta") message:NSLocalizedString(@"s000xS40", nil) delegate:self cancelButtonTitle:NSLocalizedString(@"s000xS34", @"Não") otherButtonTitles:NSLocalizedString(@"s000xS35", @"Sim"), nil];

            [alerta show];
        }else{
            UIAlertController * alert=   [UIAlertController
                                          alertControllerWithTitle:NSLocalizedString(@"s000xS2", @"Alerta")
                                          message:NSLocalizedString(@"s000xS40", nil)
                                          preferredStyle:UIAlertControllerStyleAlert];

            UIAlertAction* sim = [UIAlertAction
                                 actionWithTitle:NSLocalizedString(@"s000xS35", @"Sim")
                                 style:UIAlertActionStyleDefault
                                 handler:^(UIAlertAction * action)
                                 {
                                     [Util abrirSite:[[[Player sharedPlayer] emissora] site]];
                                     [alert dismissViewControllerAnimated:YES completion:nil];

                                 }];
            UIAlertAction* nao = [UIAlertAction
                                  actionWithTitle:NSLocalizedString(@"s000xS34", @"Não")
                                  style:UIAlertActionStyleDefault
                                  handler:^(UIAlertAction * action)
                                  {
                                      [alert dismissViewControllerAnimated:YES completion:nil];

                                  }];

            [alert addAction:sim];
            [alert addAction:nao];


            [self presentViewController:alert animated:NO completion:nil];
        }
if([[[UIDevice currentDevice]systemVersion]floatValue]<8.0){
UIAlertView*alerta=[[UIAlertView alloc]initWithTitle:NSLocalizedString(@“s000xS2”,@“alerta”)消息:NSLocalizedString(@“s000xS40”,无)委托:自取消按钮:NSLocalizedString(@“s000xS34”,@“Não”)其他按钮:NSLocalizedString(@“s000xS35”,@“Sim”),无);
[警报秀];
}否则{
UIAlertController*警报=[UIAlertController]
alertControllerWithTitle:NSLocalizedString(@“s000xS2”,@“Alerta”)
消息:NSLocalizedString(@“s000xS40”,无)
首选样式:UIAlertControllerStyleAlert];
UIAlertAction*sim=[UIAlertAction
标题为:NSLocalizedString(@“s000xS35”,@“Sim”)的操作
样式:UIAlertActionStyleDefault
处理程序:^(UIAlertAction*操作)
{
[Util abrirSite:[[Player sharedPlayer]emissora]site];
[警报解除ViewControllerInitiated:是完成:无];
}];
UIAlertAction*nao=[UIAlertAction
标题为:NSLocalizedString(“s000xS34”和“Não”)的行动
样式:UIAlertActionStyleDefault
处理程序:^(UIAlertAction*操作)
{
[警报解除ViewControllerInitiated:是完成:无];
}];
[警报添加操作:sim];
[警报添加操作:nao];
[自我呈现视图控制器:警报动画:无完成:无];
}
对于这段代码,我也有同样的问题,这些按钮没有显示在警报中,有什么建议可以解决这个问题吗

请注意,我正在使用字符串进行国际化,它们通常可以工作,已经通过直接放置字符串(@“…)进行了测试,但不起作用。

尝试以下方法:

UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"ALERTA!" message:@"What will you do?" **preferredStyle:UIAlertControllerStyleAlert**];
__weak ViewController *wself = self;

UIAlertAction *nao = [UIAlertAction actionWithTitle:@"I'm doing something" ***style:UIAlertActionStyleCancel*** handler:^(UIAlertAction *action) {
    __strong ViewController *sself = wself;
    sself.**lbl**.text = @"You did something!";   **//the text "You did something!"   gets displayed on a label(if created) named  lbl**
}];
[alert addAction:nao];
[self presentViewController:alert animated:NO completion:nil];