iOS 11 UIAlertview 未显示完整消息

iOS 11 UIAlertview not show full Message

我尝试使用 UIAlertView 为我的应用制作弹出窗口。此弹出窗口在 iOS 10 或更早版本上显示良好,但在 iOS 11 上它不显示弹出窗口的所有内容。我该怎么做才能修复该错误!? 这是我用来制作自定义 UAlertView 的代码。有什么想法吗?

UIAlertView *alert = [[UIAlertView alloc]initWithTitle:nil message:nil delegate:self cancelButtonTitle:NSLocalizedString(@"ok", nil) otherButtonTitles: nil];

UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(0,0, 900, 900)];

[lbl setAttributedText:getPopUp];

[lbl setNumberOfLines:0];

[lbl sizeToFit];

[lbl setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"bg-popup-2.png"]]];

    [alert setValue:lbl forKey:@"accessoryView"];

    [alert show];

对不起我的英语不好! 问候!感谢您的帮助!!

UIAlertView 已被弃用。而不是使用 UIAlertView 你应该像这样使用 UIAlertController :-

 UIAlertController *alertController=[UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
 UIAlertAction *actionOk=[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        //Ok Button Code
    }];
  UIAlertAction *actionCancel=[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        //Cancel Button Code
    }];
  [alertController addAction:actionOk];
  [alertController addAction:actionCancel];

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

使用 UIAlertController 而不是 UIAlertView

  UIAlertController * alert=   [UIAlertController
                                 alertControllerWithTitle:title //alert Title
                                 message:getPopUp //Your Message
                                 preferredStyle:UIAlertControllerStyleAlert];

    UIView *firstSubview = alert.view.subviews.firstObject;
    UIView *alertContentView = firstSubview.subviews.firstObject;
    for (UIView *subSubView in alertContentView.subviews) {
      subSubView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg-popup-2.png"]];
     }

   UIAlertAction* ok = [UIAlertAction
                        actionWithTitle:@"OK"
                        style:UIAlertActionStyleDefault
                        handler:^(UIAlertAction * action)
                        {
                            [alert dismissViewControllerAnimated:YES completion:nil];

                        }];


   [alert addAction:ok];

   [self presentViewController:alert animated:YES completion:nil];

希望对您有所帮助。
更多详情:http://hayageek.com/uialertcontroller-example-ios/