Я использую:
let navigationController = UINavigationController()
navigationController.modalPresentationStyle = .fullScreen
Чтобы установить модальный стиль представления, он работает для каждого представления. Но если я представляю UIImagePickerController (), он не работает.
Я использую MVVM-C
let navigationController = UINavigationController()
navigationController.modalPresentationStyle = .fullScreen
let navRouter = Router(navigationController: navigationController)
let coordinator = LibraryPictureChooseCoordinator(router: navRouter)
coordinator.onSelected = { [weak self] (image: UIImage) in
self?.router.dismissModule(animated: true, completion: nil)
self?.removeChild(coordinator)
self?.showCrop(image: image)
}
addChild(coordinator)
coordinator.start()
router.present(coordinator, animated: true)
class LibraryPictureChooseCoordinator: Coordinator<DeepLinkOption> {
let viewController: UIImagePickerController!
var onSelected: ((UIImage) -> Void)?
override init(router: RouterType) {
self.viewController = UIImagePickerController()
self.viewController.sourceType = .photoLibrary
self.viewController.allowsEditing = false
super.init(router: router)
self.viewController.delegate = self
}
override func toPresentable() -> UIViewController {
return viewController
}
}
extension LibraryPictureChooseCoordinator: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
internal func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
// Local variable inserted by Swift 4.2 migrator.
let info = convertFromUIImagePickerControllerInfoKeyDictionary(info)
let image = info[convertFromUIImagePickerControllerInfoKey(UIImagePickerController.InfoKey.originalImage)] as! UIImage
self.viewController.dismiss(animated:true, completion: nil)
self.onSelected!(image)
}
}
Это работает для просмотра, я создал свой собственный ViewController.