Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set initial viewController in Navigation controller programmatically (Layer SDK)

I want to add Layer SDK to my application (using Swift).

All view controllers here are created programmatically. Therefore I can't segue to them. I have 4 tabs in my application (UITabBarController). One of them is chat. In the chat tab I created a segue to UINavigationController. Now I want to load conversationListViewController in this UINavigationController. For that I created a class for this UINavigationController i.e. ConversationListViewController and added the following code:

class ChatNavigationViewController: UINavigationController {
  var conversationListViewController: ConversationListViewController!
    var layerClient: LYRClient!
      override func viewDidLoad() {
        let appDelegate = UIApplication.sharedApplication().delegate as!AppDelegate
        self.layerClient = appDelegate.layerClient
        self.conversationListViewController = ConversationListViewController(layerClient: appDelegate.layerClient)
        self.conversationListViewController.displaysAvatarItem = true

        self.navigationController!.pushViewController(self.conversationListViewController, animated: true)
      }
}

But this is not working. And giving this kind of effect: the ConversationViewController is not loaded in UINavigationController. I am not sure if I am doing it the correct way. I'm searching for the correct way, but unable to find.

Screenshot

like image 697
Nishant Dongare Avatar asked Jul 24 '26 14:07

Nishant Dongare


1 Answers

I Solved it. I dragged new NavigationViewController and added ConversationListViewController to rootviewController.I think i should try this first. Anyways thanks guys for your help.enter image description here

like image 131
Nishant Dongare Avatar answered Jul 27 '26 04:07

Nishant Dongare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!