最佳答案
您可以使用 UITableView
创建 View Controller 并将其呈现为 UIPopoverPresentationController
let vc = UIViewController()
vc.modalPresentationStyle = .popover
vc.preferredContentSize = CGSize(width: 200, height: 200)
let popUp = vc.popoverPresentationController
popUp?.permittedArrowDirections = .up
popUp?.delegate = self
popUp?.sourceView = sender as! UIView // here set the frame of the button that the arrow points to when popup is shown
present(vc, animated: true, completion: nil)
//
在您呈现弹出窗口的 vc 中,使其实现委托(delegate) UIPopoverPresentationControllerDelegate
并编写此方法
func adaptivePresentationStyle(for controller: UIPresentationController) -> UIModalPresentationStyle {
return .none
}
关于swift - 可以创建一个出现在 View Controller 角落的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50399083/