UIAlertView按钮标题在iOS 8中变为白色

时间:2014-10-08 07:06:08

标签: objective-c iphone ios8 uialertview

我正在使用一个有很多警报视图的旧应用程序。此应用程序在iOS7中正常工作但在iOS8中警报视图按钮文本颜色变为白色且不可见。功能明智,它也在iOS8中工作。 请参阅屏幕截图以获得更多理解。 enter image description here

1 个答案:

答案 0 :(得分:1)

您尝试此代码

  - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view from its nib.

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Alrt" message:@"This is the Message" preferredStyle:UIAlertControllerStyleAlert];
        UIAlertAction *cancelAction = [UIAlertAction
                                       actionWithTitle:NSLocalizedString(@"Cancel", @"Cancel action")
                                       style:UIAlertActionStyleCancel
                                       handler:^(UIAlertAction *action)
                                       {
                                           NSLog(@"Cancel action");
                                       }];

        UIAlertAction *okAction = [UIAlertAction
                                   actionWithTitle:NSLocalizedString(@"OK", @"OK action")
                                   style:UIAlertActionStyleDefault
                                   handler:^(UIAlertAction *action)
                                   {
                                       NSLog(@"OK action");
                                   }];

        [alertController addAction:cancelAction];
        [alertController addAction:okAction];

        [self presentViewController:alertController animated:YES completion:nil];
    }

enter image description here