Push multiple view controllers in storyboard

Mughees Musaddiq

I have three controllers (FriendVC, ChatVC, PrivateChatVC) inside storyboad, and navigation is sequential :

A user can navigate from FriendVC to ChatVC(in TabBarController), and then to PrivateChatVC.

Now, I need to make some button that will open PrivateChatVC from FriendVC but will also put ChatVC on navigation stack, so when a user will press back from PrivateChatVC he will be returned to ChatVC.

Problem I'm facing is that my ChatVC is a TabBarController.

Below is the code I'm trying:

   [self.tabBarController setSelectedIndex:1];
   PrivateChatController * privateChatController = [self.storyboard instantiateViewControllerWithIdentifier:@"privatechat"];
   [self.navigationController pushViewController:privateChatController animated:YES]; 

I'm assuming that [self.tabBarController setSelectedIndex:1] will load the tabbar and then [self.navigationController pushViewController:privateChatController animated:YES]; will load PrivateChatVC.

However, it only takes me to ChatVC and PrivateChatVC never loads.

inorganik

You're on the right track, you need to select the ChatVC tab as you've done, but use a singleton class and set a param so that when ChatVC becomes the active VC it knows to immediately push PrivateChatVC.

In FriendVC:

_singleton.showPrivateChat = YES;
[self.tabBarController setSelectedIndex:1]; // select ChatVC tab

In ChatVC:

- (void) viewDidAppear {

    if (_singleton.showPrivateChat) {
        PrivateChatController * privateChatController = [self.storyboard instantiateViewControllerWithIdentifier:@"privatechat"];
        [self.navigationController pushViewController:privateChatController animated:YES]; 
        _singleton.showPrivateChat = NO; // reset boolean
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Push multiple view controllers in storyboard

From Dev

iOS: Programmatically Push Segue to Multiple View Controllers

From Dev

Connect multiple view controllers from storyboard to code in Xcode 6

From Dev

Xcode Master-Detail storyboard multiple view controllers

From Dev

Nesting view controllers inside a storyboard

From Dev

StoryBoard - View Controllers how to switch?

From Dev

Changing view controllers without the storyboard

From Dev

How to push multiple view controllers into UINavigation but only show animation once?

From Dev

Two view controllers have the same storyboard identifier

From Dev

Using one storyboard definition for two view controllers

From Dev

Using storyboard only for certain view controllers

From Dev

PubNub and Multiple View Controllers

From Dev

Multiple Split View Controllers

From Dev

Multiple persistent view controllers

From Dev

CLLocationManager delegate / Multiple view controllers

From Dev

Yeoman Angular: Multiple controllers on a view

From Dev

Dismiss Multiple Pushed View Controllers

From Dev

Multiple view controllers with different orientations

From Dev

Multiple View Controllers - iOS 7

From Dev

Present multiple modal view controllers?

From Dev

Multiple view controllers in a single scene?

From Dev

How to move to multiple view controllers?

From Dev

SWReveal Menu on Multiple View Controllers

From Dev

Showing and Popping Multiple View Controllers

From Dev

SWReveal Menu on Multiple View Controllers

From Dev

Multiple view controllers with different orientations

From Dev

SWRevealViewController - push next view controller storyboard

From Dev

IOS screen is black when storyboard has view controllers

From Dev

Unable to solve the 'NSUnknownKeyException' error if view controllers are in a library and storyboard in different project

Related Related

  1. 1

    Push multiple view controllers in storyboard

  2. 2

    iOS: Programmatically Push Segue to Multiple View Controllers

  3. 3

    Connect multiple view controllers from storyboard to code in Xcode 6

  4. 4

    Xcode Master-Detail storyboard multiple view controllers

  5. 5

    Nesting view controllers inside a storyboard

  6. 6

    StoryBoard - View Controllers how to switch?

  7. 7

    Changing view controllers without the storyboard

  8. 8

    How to push multiple view controllers into UINavigation but only show animation once?

  9. 9

    Two view controllers have the same storyboard identifier

  10. 10

    Using one storyboard definition for two view controllers

  11. 11

    Using storyboard only for certain view controllers

  12. 12

    PubNub and Multiple View Controllers

  13. 13

    Multiple Split View Controllers

  14. 14

    Multiple persistent view controllers

  15. 15

    CLLocationManager delegate / Multiple view controllers

  16. 16

    Yeoman Angular: Multiple controllers on a view

  17. 17

    Dismiss Multiple Pushed View Controllers

  18. 18

    Multiple view controllers with different orientations

  19. 19

    Multiple View Controllers - iOS 7

  20. 20

    Present multiple modal view controllers?

  21. 21

    Multiple view controllers in a single scene?

  22. 22

    How to move to multiple view controllers?

  23. 23

    SWReveal Menu on Multiple View Controllers

  24. 24

    Showing and Popping Multiple View Controllers

  25. 25

    SWReveal Menu on Multiple View Controllers

  26. 26

    Multiple view controllers with different orientations

  27. 27

    SWRevealViewController - push next view controller storyboard

  28. 28

    IOS screen is black when storyboard has view controllers

  29. 29

    Unable to solve the 'NSUnknownKeyException' error if view controllers are in a library and storyboard in different project

HotTag

Archive