Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

182
Visualizações
How to grow a popover controller

I have a popover controller in my app for iPad and Mac (using mac catalyst) and I'm trying to figure out how to grow the height of the popover when it's already presented. I've been searching everywhere on how to do this but everything I find is about setting the size before presenting but not after.

While the pop-up is presenting, there's a button in it that should grow the height by 100-150 pixels, but I can not figure out how

Can anyone please help me with this? Thank you in advance!

Here's my popover presenting code:

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 Respostas
Responde à pergunta

0

To change a size of your presented controller in popover view you should modify its preferredContentSize property:

@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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda