iOS 11 UIAlertview не показывает полное сообщение - PullRequest
0 голосов
/ 17 мая 2018

Я пытаюсь создать всплывающее окно для моего приложения с помощью 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];

Click here to see example

Извините за мой плохой английский! С уважением! спасибо за вашу помощь !!

Ответы [ 2 ]

0 голосов
/ 17 мая 2018

Используйте 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/

0 голосов
/ 17 мая 2018

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];
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...