Present View Controller in Storyboard with a Navigation Controller - Swift

后端 未结 5 1302
眼角桃花
眼角桃花 2021-01-30 10:30

I am currently showing a viewController in my new storyboard below:

var storyboard : UIStoryboard = UIStoryboard(name: AccountStoryboard, bundle: nil)
var vc : W         


        
5条回答
  •  后悔当初
    2021-01-30 11:20

    Remember to setup the modalPresentationStyle property, in programmatically present the IB settings are ignored.

    let sb = UIStoryboard(name: "retail_carrello", bundle: nil)
        guard let carrelloVC = sb.instantiateViewController(withIdentifier: "mainCarrello") as? retail_carrello else { return }
    
        let navController = UINavigationController(rootViewController: carrelloVC)
    
        navController.modalPresentationStyle = .fullScreen //<--- remember to set up this if you need fullscreen
    
         present(navController, animated: true, completion: nil)
    

提交回复
热议问题