I am trying to present a view controller from a UIScrollView subview. I've tried using AppDelegate window.rootViewController presentViewController: but that gives me the "view is not in the hierarchy!" error. I want to avoid using addSubview because that breaks MVC and seems to remove the controller's functionality (buttons stop working). When I use the expected presentViewController method, I get "No visible @interface for "InititalScrollViewSubview" declares the selector "presentViewController:animated:completion:", which I think means that my initialScrollViewSubview is trying to use presentViewController but presentViewController has to come from a UIViewController. UIScrollView is without the presentViewController method.
My code is something like:
-(void)setupTouchIDButtonTapped: (id)sender {
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"newViewController" bundle:nil];
NewViewController *myNewViewController = [storyboard instantiateViewControllerWithIdentifier:@"myNewVC"];
//First thing I tried:
AppDelegate *delegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
[delegate.window.rootViewController presentViewController:NewViewController animated:YES completion:nil];
//second thing I tried
[self addSubview:NewViewController.view];
//third thing I tried:
[self presentViewController:NewViewController animated:YES completion:nil];
}
The InitialScrollViewSubview has to remain the way it is. Ideally, I'd refactor everything so the InitialScrollViewSubview is another UIViewController but I work for a huge company and the app is way too large :) Any advice is greatly appreciated!!
Thanks!!