Estoy tratando de hacer una ventana emergente menú con el siguiente código:
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
}
}
Esto está funcionando en el iPad, pero, en un iPhone, la ventana emergente que se toma toda la pantalla del iPhone. Yo sólo quiero una pequeña ventana con una flecha. He encontrado varios tutoriales pero ninguno funcionó para mí.
- hasta donde yo sé, esa es la intención de comportamiento por parte de apple, no hay pop-ups en el iphone
- el código que está funcionando para mí…. pero el delegado no es correcto
Cambiar su método de delegado a: