UIPopoverArrowDirection.down 不适用于 iOS

UIPopoverArrowDirection.down is not working for iOS

我正在尝试在我的 Tabbarview 控制器上显示带有向下箭头的弹出窗口 viewcontroller,但是如果我选择向下,它就会停止出现,如果是向上,它就会显示。

所以我的问题是

1) 如果 UIPopoverArrowDirection.down 不起作用,如何使箭头向下?为什么它不起作用?

2) 如何调试并找到为什么不显示的错误,没有为此打印日志。

3)如何在视图中心而不是侧面显示箭头。

我的代码是,

 let popController = UIStoryboard(name: kStoryboard.login, bundle: nil).instantiateViewController(withIdentifier: "popoverId")

        popController.modalPresentationStyle = UIModalPresentationStyle.popover
        popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.down
        popController.popoverPresentationController?.backgroundColor = UIColor.Text.orange
        popController.popoverPresentationController?.delegate = self
        popController.popoverPresentationController?.sourceView = self.view
        popController.popoverPresentationController?.sourceRect = CGRect(x: 0, y: 0, width: 100, height: 100)

        // present the popover
        self.present(popController, animated: true, completion: nil)




func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle
    {
        return UIModalPresentationStyle.none
    }

我已经从情节提要中给出了 preferredcontentsize。

问题是目前您没有提供 sourceView + preferredContentSize

import UIKit

class ViewController: UIViewController , UIPopoverPresentationControllerDelegate{

    @IBOutlet weak var aa: UIButton!
    override func viewDidLoad() {
        super.viewDidLoad()


     }

    override func viewDidAppear(_ animated: Bool)
    { 

      let popController = UIStoryboard(name:"Main", bundle: nil).instantiateViewController(withIdentifier: "popoverId")
      popController.modalPresentationStyle = UIModalPresentationStyle.popover
      popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.down
      popController.popoverPresentationController?.backgroundColor = UIColor.red
      popController.popoverPresentationController?.delegate = self
      popController.popoverPresentationController?.sourceView = self.aa
      popController.popoverPresentationController?.sourceRect = CGRect(x: 20, y: 20, width: 100, height: 100)

      popController.preferredContentSize = CGSize.init(width: 200, height: 200)
    // present the popover
     self.present(popController, animated: true, completion: nil)



    }

    func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle
    {
        return UIModalPresentationStyle.none
    }

}