Отображение всплывающего окна с TextField - клавиатура вызывает мерцание - PullRequest
1 голос
/ 12 марта 2020

Мне было интересно, сталкивался ли кто-нибудь со странным мерцанием / анимацией с помощью PopoverPresentationController. Мерцание возникает, когда текстовое поле становится первым респондентом. Похоже, что поповер почти снова открывается поверх существующего поповера.

Шаги / Разбивка приложения:

MainViewController - UIViewController с табличным представлением

public override void ViewDidLoad() {
  base.ViewDidLoad();
  source = new TableSource(this);
  tableView = new UITableView(CoreGraphics.CGRect.Empty, UITableViewStyle.Grouped);
  tableView.TranslatesAutoresizingMaskIntoConstraints = false;
  tableView.RegisterClassForCellReuse(typeof(TableViewCell), "test");
  tableView.Source = source;
  View.AddSubview(tableView);

  source.Source.Add(new List<string> { 
    "Section 1, text Element 0",
    "Section 1, text Element 1",
    "Section 1, text Element 2",
    "Section 1, text Element 3",
    "Section 1, text Element 4",
    "Section 1, text Element 5",
    "Section 1, text Element 6",
   });

  tableView.TopAnchor.ConstraintEqualTo(View.TopAnchor).Active = true;
  tableView.LeftAnchor.ConstraintEqualTo(View.LeftAnchor).Active = true;
  tableView.RightAnchor.ConstraintEqualTo(View.RightAnchor).Active = true;
  tableView.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true;
}

PopoverView - UIViewController с простым TextField

public class PopoverView: UIViewController {
  public override void ViewDidLoad() {
    base.ViewDidLoad();
    UITextField field = new UITextField(new CGRect(20,10, 150, 44));
    field.BackgroundColor = UIColor.White;
    View.AddSubview(field);
  }
}

1) Нажмите на ячейку

public override void RowSelected(UITableView tableView, NSIndexPath indexPath) {
  PopoverView view = new PopoverView();
  view.View.BackgroundColor = UIColor.LightGray;
  view.ModalPresentationStyle = UIModalPresentationStyle.Popover;
  view.PopoverPresentationController.SourceRect = new CoreGraphics.CGRect(0, 40, 100, 100);
  view.PopoverPresentationController.SourceView = tableView;
  view.PreferredContentSize = new CoreGraphics.CGSize(300, 1000);
  controller.PresentViewController(view, true, null);
}

2) запускает поповер 3) щелкните текстовое поле

Если я изменю следующую строку в RowSelected:

view.PopoverPresentationController.SourceRect = new CoreGraphics.CGRect(0, 40, 100, 100);

на:

view.PopoverPresentationController.SourceRect = new CoreGraphics.CGRect(0, 0, 100, 100);

мерцание прекращается, однако это не помогает, если всплывающее окно связано с ячейками таблицы в разных местах на экране.

...