Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

180
Views
Cómo hacer crecer un controlador popover

Tengo un controlador de popover en mi aplicación para iPad y Mac (usando Mac Catalyst) y estoy tratando de descubrir cómo aumentar la altura del popover cuando ya está presentado. He estado buscando en todas partes cómo hacer esto, pero todo lo que encuentro se trata de establecer el tamaño antes de presentar, pero no después.

Mientras se presenta la ventana emergente, hay un botón que debería aumentar la altura entre 100 y 150 píxeles, pero no puedo entender cómo

¿Puede alguien por favor ayudarme con esto? ¡Gracias de antemano!

Aquí está mi código de presentación popover:

 func openView(sourceView: UIView?, sourceRect: CGRect?) { let vc = ViewControllerA() //Try popover if let sourceView = sourceView, let sourceRect = sourceRect { vc.modalPresentationStyle = .popover if let popover = vc.popoverPresentationController { vc.preferredContentSize = return CGSize(width: 390, height: 390) vc.presentationController?.delegate = self popover.sourceView = sourceView popover.sourceRect = sourceRect popover.permittedArrowDirections = [.up, .left] self.present(vc, animated: true, completion: nil) return } } //present it normally if there's no source view vc.modalPresentationStyle = .overCurrentContext vc.modalTransitionStyle = .crossDissolve self.present(vc, animated: true, completion: nil) }
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Para cambiar el tamaño de su controlador presentado en la vista emergente, debe modificar su propiedad preferredContentSize :

 @IBAction func showPopover(_ sender: UIButton) { // Create controller guard let controller = storyboard?.instantiateViewController(withIdentifier: "Popover") else { return } controller.modalPresentationStyle = .popover controller.preferredContentSize = CGSize(width: 200, height: 200) // Configure popover guard let popover = controller.popoverPresentationController else { return } popover.permittedArrowDirections = .up popover.sourceView = self.view popover.sourceRect = sender.frame popover.delegate = self present(controller, animated: true, completion: nil) // Change height after 3 secs DispatchQueue.main.asyncAfter(deadline: .now() + 3) { controller.preferredContentSize = CGSize(width: 200, height: 400) } }
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!