如何在swift中的NSObject子类中使用UIPresentationController

时间:2017-11-21 04:41:55

标签: swift xcode uipopovercontroller uipopoverpresentationcontroller

var popVC:UIPopoverController?
popVC = UIPopoverController(contentViewController: viewControl)
popVC?.delegate = self
popVC?.setContentSize(highlight!.frame.size, animated: false)
highlight?.popVC = popVC
if let dir = self.phData.direction {
        var popDir = UIPopoverArrowDirection.any
        switch dir {
        case "left":
            popDir = UIPopoverArrowDirection.left
            break
        case "right":
            popDir = UIPopoverArrowDirection.right
            break
        case "top":
            popDir = UIPopoverArrowDirection.up
            break
        case "down":
            popDir = UIPopoverArrowDirection.down
            break
        default:
            break
        }
        popVC?.present(from: self.frame, in: inView, permittedArrowDirections: popDir, animated: true)
  }else{
        popVC?.present(from: self.frame, in: inView, permittedArrowDirections: UIPopoverArrowDirection.any, animated: true)
    }

以上代码已弃用,现在我想将其更改为UIPopoverPresentationController。我试着搜索答案,但后来答案不适合NSObject子类,所以我很困惑。请帮我。 提前谢谢。

0 个答案:

没有答案