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

254
Views
El cajón de navegación inferior no aparece (Swift)

Actualmente estoy trabajando en una aplicación iOS y quiero usar un cajón de navegación inferior de material-io. Así que lo hice como se explica en los ejemplos del sitio . Pero cuando presento el Cajón de navegación, el ViewController solo se oscurece un poco y no se muestra la vista de contenido del cajón.

Aquí está mi código:

 import Foundation import UIKit import MaterialComponents class CreateSubjectView: UIViewController, UITextFieldDelegate { ... override func viewDidLoad() { ... let bottomDrawerViewController = MDCBottomDrawerViewController() self.modalPresentationStyle = .popover let newViewController = self.storyboard?.instantiateViewController(withIdentifier: "TEST") bottomDrawerViewController.contentViewController = newViewController present(bottomDrawerViewController, animated: true, completion: nil) ... } ... }
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

El controlador de vista que se mostrará en el cajón debe tener un tamaño de contenido preferido especificado.

Aquí hay una demostración del controlador mínimo. ( Nota: modalPresentationStyle = .popover no tiene efecto en MDCBottomDrawerViewController )

Probado con Xcode 12

manifestación

 // button action in parent controller @objc private func presentNavigationDrawer() { let bottomDrawerViewController = MDCBottomDrawerViewController() bottomDrawerViewController.contentViewController = DemoViewController() present(bottomDrawerViewController, animated: true, completion: nil) } } class DemoViewController: UIViewController { override func loadView() { super.loadView() let view = UIView() view.backgroundColor = .red self.view = view } override func viewDidLayoutSubviews() { super.viewDidLayoutSubviews() // specify your content preferred height explicitly self.preferredContentSize = CGSize(width: 0, height: 400) // required !! } @available(iOS 11.0, *) override func viewSafeAreaInsetsDidChange() { super.viewSafeAreaInsetsDidChange() // specify your content preferred height explicitly self.preferredContentSize = CGSize(width: 0, height: 400) // required !! } }
over 4 years ago · Santiago Trujillo Report

0

Mueva esto a viewWillAppear / viewDidAppear una vez, ya que es demasiado pronto para que viewDidLoad presente un vc

 class CreateSubjectView: UIViewController, UITextFieldDelegate { let bottomDrawerViewController = MDCBottomDrawerViewController() var once = true override func viewDidLoad() { super.viewDidLoad() } override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) if once { let newViewController = self.storyboard?.instantiateViewController(withIdentifier: "TEST") bottomDrawerViewController.contentViewController = newViewController present(bottomDrawerViewController, animated: true, completion: nil) once = false } } }
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!