提问人:Robert 提问时间:3/12/2020 最后编辑:Robert 更新时间:3/12/2020 访问量:250
使用 TextField 显示弹出框 - 键盘导致闪烁
Displaying a popover with TextField - keyboard cause a flicker
问:
我想知道是否有人遇到过 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);
闪烁停止,但是,如果弹出框链接到屏幕上不同位置的 TableView 单元格,则无济于事。
答: 暂无答案
评论