Ios13 Uipopoverviewcontroller Showing Uitableviewcontroller - Safe Area Problems/Missing Parts of Table

ios13 UIPopoverViewController showing UITableViewController - Safe Area problems / Missing parts of table

Okay, so I used up a support ticket with Apple over this - after a year on here with no answers.

The old way (setting the border on the popover) will never work again because of the under-the-hood auto layout stuff going on with the UITableViewController and it's UITableView.

The only solution is to remove the UITableViewController completely, and replace it with a UIViewController, with a single view in it, and inside that view, place a UITableView.

Thankfully the code changes are minimal (just changing the inheritance from UITableViewController to UIViewController, and then add a UITableViewDelegate in)

Then make sure that the UIViewController containing the table sets itself as the UITableView's delegate and source.

The longest part of the fix is recreating the layout in Interface Builder, but this time make sure the UITableView doesn't get it's top, leading, bottom, trailing to the SUPERVIEW, but instead to the SAFE AREA.

Then all you need to do is put this in, and it works:

override func viewDidLoad()
{
super.viewDidLoad()

self.tableView.delegate = self
self.tableView.dataSource = self

self.tableView.layer.borderWidth = 5
self.tableView.layer.borderColor = UIColor.white.cgColor
self.tableView.layer.cornerRadius = 16
}

UITableViewController and safe area

What you’re seeing is normal and correct. The table view is the entire view of the view controller and covers the whole screen. It still works fine because the scrolling content is inset, so the user can scroll to see all parts of the table; the top of the table is inset down. So all is well.

If you really want the effect shown in your last screen shot, you’ll have to make the table view controller a child view controller of some other view controller. A typical interface is to wrap the table view controller in a navigation controller so that the nav bar fills the top of the screen. Or you could manually use a container view / embed segue.

iOS: Problem of display the popover border in the iOS13

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 ! ;-)



Related Topics



Leave a reply



Submit