在Ipad上使用UITableview Longpress进行操作表操作的最佳方法是什么

时间:2017-03-29 02:42:21

标签: ios swift

我有一个tableview,在长按时会显示警告。它在iphone上工作正常但在ipad上我得到了popover错误。问题是该表不是一个按钮,我在单元格上没有按钮,解决此问题的最佳方法是什么?请看一下我的代码。

 func ipadPresentationAlert(button:UIButton, alertController:UIAlertController){
        if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad ){
            if let currentPopoverpresentioncontroller = alertController.popoverPresentationController{
                currentPopoverpresentioncontroller.sourceView = button
                currentPopoverpresentioncontroller.sourceRect = button.bounds;
                currentPopoverpresentioncontroller.permittedArrowDirections = UIPopoverArrowDirection.up;
                self.present(alertController, animated: true, completion: nil)
            }
        }else{
            self.present(alertController, animated: true, completion: nil)
        }
    }

1 个答案:

答案 0 :(得分:1)

您可以通过yourCell替换按钮。

button:UIButton -> cell: UITableViewCell

在iPad上,ActionSheet需要显示一个sourceView,因此您可以将您的单元格放在这里作为支点。

currentPopoverpresentioncontroller.sourceView = cell
相关问题