我試圖讓酥料餅的菜單用下面的代碼:酥料餅在SWIFT 3 iPhone iOS上
import UIKit
class BeobachtungViewController: UIViewController, UIPopoverPresentationControllerDelegate {
@IBAction func addClicked(_ sender: AnyObject) {
// get a reference to the view controller for the popover
let popController = UIStoryboard(name: "Personenakte", bundle: nil).instantiateViewController(withIdentifier: "popoverId")
// set the presentation style
popController.modalPresentationStyle = UIModalPresentationStyle.popover
// set up the popover presentation controller
popController.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.up
popController.popoverPresentationController?.delegate = self
popController.popoverPresentationController?.sourceView = sender as! UIView // button
popController.popoverPresentationController?.sourceRect = sender.bounds
// present the popover
self.present(popController, animated: true, completion: nil)
}
// UIPopoverPresentationControllerDelegate method
func adaptivePresentationStyleForPresentationController(controller: UIPresentationController) -> UIModalPresentationStyle {
// Force popover style
return UIModalPresentationStyle.none
}
}
這是工作的iPad,但是,在iPhone上,彈出佔用了整個iPhone的屏幕。我只想要一個帶箭頭的小窗戶。我發現了幾個教程,但都沒有爲我工作。
據我所知,這是蘋果的預期的行爲,則對iphone – Fonix
你的代碼它的工作對我來說沒有彈出....但你的委託這是不正確的 – TonyMkenu