Search code examples
iosswiftuipopovercontroller

iOS: Problem of display the popover border in the iOS13


The popover that I display is now bad displayed. There is a line missing on the arrow side. We can check that there is a little piece of black just at the end of the arrow. I think there is a view inside that is too long.

Code to display the popover:

   _popoverController = UIPopoverController(contentViewController: navController)
   _popoverController?.delegate = self

   let rect = slotCollectionView.cellForItem(at: indexPath)!.frame
   self._popoverController?.backgroundColor = UIColor.init(rgb: Int(quaternaryColorHexa))
   self._popoverController?.present (from: rect, in: self.slotCollectionView, permittedArrowDirections: UIPopoverArrowDirection.any, animated: true) 

Code to init Popover:

override func viewDidLoad()
{
    super.viewDidLoad()

    self.preferredContentSize = contentSize()
    self.navigationController!.preferredContentSize = self.preferredContentSize;

    peopleTableView.isScrollEnabled = true
    peopleTableView.bounces = true
    peopleTableView.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 0))
    peopleTableView.tableFooterView?.isHidden = true
    peopleTableView.backgroundColor = UIColor.init(rgb: Int(quinquenaryColorHexa))

    self.view.backgroundColor = UIColor.init(rgb: Int(quinquenaryColorHexa))
    self.view.layer.cornerRadius = 13.0
    self.view.layer.borderWidth = 1.5
    self.view.layer.borderColor = UIColor.init(rgb: Int(quaternaryColorHexa)).cgColor 

iOS12 display:
iOS12
iOS13 display:
iOS13


Solution

  • I think it is an iOS bug in the iOS13 version, and I advice you to do your own popover by using that git project:
    DDPopoverBackgroundView

    and using this for displaying the popover:

           // Popover
           _popoverController = UIPopoverController(contentViewController: navController)
           _popoverController?.delegate = self
    
           let rect = slotCollectionView.cellForItem(at: indexPath)!.frame
    
           self._popoverController!.contentSize = CGSize(width: 350, height: 600)
    
           self._popoverController!.backgroundViewClass = DDPopoverBackgroundView.self
           self._popoverController!.backgroundColor = UIColor.init(rgb: Int(quaternaryColorHexa)) //arrow color
    
           OperationQueue.main.addOperation({
               self._popoverController?.present(from: rect, in: self.slotCollectionView, permittedArrowDirections: UIPopoverArrowDirection.any, animated: true)
           })
    

    enjoy ! ;-)