2

我想知道是否有人使用 PopoverPresentationController 遇到了奇怪的闪烁/动画。当有一个 textField 成为第一响应者时会发生闪烁。弹出框似乎几乎在现有弹出框的顶部重新打开。

步骤/应用程序细分:

MainViewController - 带有 tableview 的 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 - 带有简单 TextField 的 UIViewController

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) 单击 textField

如果我在 RowSelected 中更改以下行:

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

至:

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

闪烁停止但是如果弹出框链接到屏幕上不同位置的表格视图单元格,则无济于事。

4

0 回答 0