Подтвердить что ты не робот

Popover в быстром 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. Я просто хочу маленькое окно со стрелкой. Я нашел несколько учебников, но никто не работал у меня.

4b9b3361

Ответ 1

Измените свой метод делегирования на:

func adaptivePresentationStyle(for controller: UIPresentationController, traitCollection: UITraitCollection) -> UIModalPresentationStyle {
    // return UIModalPresentationStyle.FullScreen
    return UIModalPresentationStyle.none
}