Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to display UIViewController from a NSObject class?

There is a current view as UIViewController which call "LoginView" but I'm not in, I'm in a NSObject class and I want to call, display an other UIViewController which is call "MapView". How can I do this?enter image description here

The problem is like above screenshot.

like image 252
emy Avatar asked Oct 19 '12 13:10

emy


2 Answers

I used like this in my NSObject class:

[[[UIApplication sharedApplication] delegate].window.rootViewController presentViewController:yourMapViewContorller animated:YES completion:nil];

I hope it's useful.

like image 141
snow.wang Avatar answered Oct 09 '22 04:10

snow.wang


At your IBAction or specific method write this:

UIWindow *window=[UIApplication sharedApplication].keyWindow;
UIViewController *root = [window rootViewController];

UIStoryboard *storyboard = root.storyboard;
CustomViewController *vcc =(CustomViewController *) [storyboard instantiateViewControllerWithIdentifier:@"storyBoardID"];

[root presentModalViewController:vcc animated:YES];
like image 41
Arben Pnishi Avatar answered Oct 09 '22 03:10

Arben Pnishi