Reputation: 8472
I have a storyboard based Single View App;
I have 3 ViewControllers
on my Storyboard linked to 3 ViewController
classes in the code;
I browse between ViewControllers
by doing this:
UIStoryboard* sb = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:[NSBundle mainBundle]];
MenuViewController* mainMenu = [sb instantiateViewControllerWithIdentifier:@"vcMainMenu"];
mainMenu.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentModalViewController:mainMenu animated:YES];
Now I need to access different UIcontrols
on the applicationWillResignActive
from the current active ViewController
, I will access different controls depending of the ViewController
, I'm trying to accomplish this by doing:
if ([self.window.rootViewController isKindOfClass:[LowProfileViewController class]])
{
NSLog(@"here!");
}
But it always returns the rootViewController
. How Can I get the current displayed rootViewController
from applicationWillResignActive
?
Please, Incorporate NavigationController
is not an option...
thanks
Upvotes: 1
Views: 1116
Reputation: 24248
You could try this -
Make An AppDelegate
@property
(i.e. currentModelViewController
)
@property (nonatomic, retain) UIViewController *currentModelViewController;
For each ViewController
s in viewDidAppear
or in viewWillAppear
appDelegate = [[UIApplication sharedApplication] delegate];
appDelegate.currentModelViewController = self;
Now this will work
if ([self.currentModelViewController isKindOfClass:[LowProfileViewController class]])
{
NSLog(@"here!");
}
Upvotes: 5