1
votes

My app has 3 main navigation controllers, each has its own navigation stack.
I want to enable swiping between those 3 views (the navigation controller's views).
But if user navigate inside one of them (push another view controller) I want to disable the scroll to the other navigation controllers until he will return to the root controller.

Until now this is what I did:
-I created a container controller that has scrollview as subview
-I created those 3 navigation controllers, added them as a child to the container controller and added their views as the scrollview's subviews.

So now i can scroll between those 3 navigation controllers, but the problem is when I push another view controller in one of them, I can still scroll left/right to the other ones.

I'm looking for some elegant solution for this problem, and not just disable/enable scroll in viewDidApear/viewDidDisapear

1
What is the problem with disabling/enabling scroll ? Making Custom Class for your 3 roots Controller and handle it in their viewDidApear/viewDidDisapear does not seem that dirty to me ...KIDdAe
viewDidAppear is active all the time so you want to minimise codes that you put in there.Paulo

1 Answers

0
votes

Try putting the code in one of the NavigationController delegate methods - Note all your NavigationController.delegate should be set to self.

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated  {

      if (viewController == RootviewController1 || viewController == RootvirewController2 || viewController = RootviewController3)  {
             scrollview.ScrollEnabled = YES; }
     else {
             scrollview.ScrollEnabled = NO; }

 return;
 }

,