Alosyius
Alosyius

Reputation: 9121

iOS change view controller from the app delegate?

enter image description here

Above is the storyboard for my chat app. What you'r not seeing to the left before the Navigation Controller is a simple login view. The Storyboard Segue identifier to the Navigation Controller is mainViewC.

What i want to do is to take the user to the Conv View Controller when a push notification is pressed.

This is what i've got so far:

// AppDelegate.h
@property (strong, nonatomic) ConvViewController *convViewController;

// AppDelegate.m
self.window.rootViewController = self.convViewController;

This takes me to the correct view but the view is black. Im guessing this has something to do with the Navigiation Controller not being loaded correctly..

Any ideas?

Upvotes: 1

Views: 2559

Answers (1)

Peter Foti
Peter Foti

Reputation: 5654

What you'll need to do is access the view controller from the story board. First go to the VC you wish to bring users to and give it a Storyboard ID. Then in your app delegate you would write.

self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"identifier"];

Upvotes: 4

Related Questions