0

I'm trying to present a tabbar controller programmatically using the two methods below: ( but both methods are failing).

var window: UIWindow?
let storyboard : UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let myTabBar = storyboard.instantiateViewController(withIdentifier: "happy")
window?.rootViewController = myTabBar

I tested it on iOS 12, it works. But, when changing to iOS 13, it doesn't.

Another method: ( not tested on iOS 12).

let newVC = tabBarController?.storyboard?.instantiateViewController(withIdentifier: "okplz")
 tabBarController?.present(newVC!, animated: true, completion: nil)

storyboard

AliDeV
  • 213
  • 2
  • 10
  • 1
    I'm assuming you're setting the rootviewcontroller in the appDelegate? In iOS 13 you need to set it in SceneDelegate. – valosip Oct 26 '19 at 03:41
  • Possible duplicate of [Xcode 11 & iOS13, using UIKIT can't change background colour of UIViewController](https://stackoverflow.com/questions/58251425/xcode-11-ios13-using-uikit-cant-change-background-colour-of-uiviewcontroller) – valosip Oct 26 '19 at 03:42
  • thanks, man! that was an easy, great fix! I've added it in the ScenceDelegte instead of appDelegate. – AliDeV Oct 26 '19 at 03:49

1 Answers1

0

The solution was to add the code in the SceneDelegate instead of appDelegte as answered by @valosip.

AliDeV
  • 213
  • 2
  • 10