We only see the crashes on iPad, but we have a lot more functionality on iPad than iPhone, so it's possible the culprit flow is not available on iPhone.
We call setUpPopoverPresentation in several different places. Here are snippets of how it is called:
// BorderedButton is a subclass of UIButton
private let button = BorderedButton(
normal: ColorPalette.LiveMessage.messageButtonBorderNormal,
highlighted: ColorPalette.LiveMessage.messageButtonBorderHighlighted)
...
let popoverPresentationController = messagePopoverViewController.setUpPopoverPresentation(
sourceView: button, sourceRect: button.bounds)
// within a method for creating dropdown popovers with table views - sourceView is of type UIView
let popoverPresentationController = dropdownTable.setUpPopoverPresentation(
sourceView: sourceView, sourceRect: sourceView.bounds.inset(.init(all: -5)))
@IBOutlet weak var borderLabel: UILabel! //from scene in storyboard
...
let anchorX = borderLabel.frame.width / 2
let anchorY = borderLabel.frame.height
let popoverPresentationController = tableViewController.setUpPopoverPresentation(
sourceView: borderLabel, sourceRect: CGRect(x: anchorX, y: anchorY, width: 0, height: 0))
popoverPresentationController.permittedArrowDirections = .up
present(tableViewController, animated: true, completion: nil)
guard let senderView = sender as? UIView else {
return
}
let sourceRect =
CGRect(x: senderView.bounds.midX, y: senderView.bounds.maxY, width: 0, height: 0)
let popoverPresentationController = optionsViewController.setUpPopoverPresentation(
sourceView: senderView, sourceRect: sourceRect)
popoverPresentationController.permittedArrowDirections = .up
settingsContactViewController.present(optionsViewController, animated: true, completion: nil)
// sourceView passed in is a UIButton
func setPopoverPresentationInfo(sourceView: UIView, sourceRect: CGRect) {
let popoverPresentationController =
setUpPopoverPresentation(sourceView: sourceView, sourceRect: sourceRect)
popoverPresentationController.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
popoverPresentationController.delegate = self
popoverPresentationController.popoverBackgroundViewClass = KeyboardPopoverBackgroundView.self
view.setNeedsLayout()
}
Topic:
UI Frameworks
SubTopic:
UIKit
Tags: