PopOverController出现在所选单元格旁边

时间:2016-01-07 16:59:25

标签: ios xamarin

我正在Xamarin.iOS平台上的tableviewcontroller上工作。

当用户单击tableview中第一部分的第二行时,以下代码有效。

当用户点击时,会出现弹出视图。但是,弹出窗口的位置不会出现在所选单元格的旁边。我该怎么处理?

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
  if (indexPath.Row == 1 && indexPath.Section == 0) {
    var vc = new IViewController (this,ivc.iInfo);
    var nc = new NavigationController (vc);
    nc.PreferredContentSize = new System.Drawing.SizeF (200, 300);
    UIPopoverController popupoverController = new UIPopoverController (nc);
    popupoverController.PresentFromRect (tableView.Bounds, tableView, UIPopoverArrowDirection.Any, true);
}

1 个答案:

答案 0 :(得分:1)

您应该使用选定的单元格,而不是使用tableView

UITableViewCell cell = tableView.CellAt(indexPath);
popupoverController.PresentFromRect (cell.Bounds, cell, UIPopoverArrowDirection.Any, true);