Ich versuche, ein popover Menü mit dem folgenden Code zu machen:Popover in swift 3 auf 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
}
}
Dieses auf iPad arbeitet, aber auf einem iPhone, nimmt das Fenster den ganzen iPhone-Bildschirm. Ich möchte nur ein kleines Fenster mit einem Pfeil. Ich habe mehrere Tutorials gefunden, aber keine funktionierte für mich.
soweit ich weiß, dass das gewünschte Verhalten von Apfel, gibt es für mich keine Pop-ups auf iphone – Fonix
Code es funktioniert .... aber Ihre Stellvertretung es ist nicht korrekt – TonyMkenu