0

The problem, My home screen is wrapped in a UINavigationController, when I push to the next controller it's fine, but then when I use the left swipe to go back to the home screen then click on the button to take me to the next controller sometimes it works fine about 60% other times it just hangs there. I can see the code executing in my logs as if the view controller has been presented but it's not on screen...

So at this point the whole UI is unresponsive, the only thing I can do is swipe from Left to Right like I want to go back to another page, but this is where it gets funky, the screen that I was trying to display then slides in view from the right side of the screen.

When I let go it reloads the home view, then the app works as designed.

I have no idea whats going on with this thing... Below is my code for presenting the next view:

    NextViewController *nextViewController = (NextViewController*)[self.storyboard instantiateViewControllerWithIdentifier:@"NextViewController"];
    nextViewController.nameString = [[self.topArray objectAtIndex:[indexPath row]] objectForKey:@"Name"];
    nextViewController.championMCID = [[self.topArray objectAtIndex:[indexPath row]] objectForKey:@"UserId"];
   [self.navigationController pushViewController:nextViewController animated:YES];

When I get to the next screen because i'm hiding the navigationbar, I am setting the following:

[[self navigationController]setNavigationBarHidden:YES animated:NO];

self.navigationController.interactivePopGestureRecognizer.delegate = self;

And that's it, not quite sure what's going on but any help would be great help thanks.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
C-H-E-F
  • 165
  • 11
  • Just a wild guess, but the symptoms look like some UI code running on the background thread. Check the code responsible for navigating between views and see if all is executed on the main thread. – lawicko Sep 08 '17 at 16:53
  • The code above is the code that is executed when I click on a users name. i'm not dispatching anything to another thread. above that code is this: - (IBAction)mcNameClicked:(id)sender { CGPoint buttonPosition = [sender convertPoint:CGPointMake(5,5) toView:topTenMCTable]; NSIndexPath *indexPath = [topTenMCTable indexPathForRowAtPoint:buttonPosition]; NSInteger row = indexPath.row; NSLog(@"%ld row", (long)row); if (row >= 0) { – C-H-E-F Sep 08 '17 at 17:19
  • I was running code in my viewwillappear method to hand some UI elements (settings of buttons/labels) when the user clicks and as the second view loads, and thought maybe that was the issue moved it to the viewdidload same issue occurring. As well. – C-H-E-F Sep 08 '17 at 17:20
  • I have a hunch that this is an issue with you setting the interactivePopGestureRecognizer.delegate to self of the loaded viewController. Are you clearing this delegate when you pop the ViewController? – Chris Allwein Sep 08 '17 at 18:08
  • I actually had commented out both code (popgesture && navigationbarhidden) so that it shows the navigation on both the home and pushing screen and still it hangs and does this weird glitchy stuff. I think it happens more when i've pushed to three view controllers and then slide left pop 3 view controllers. then try to move forward 1 view controller. I'm able to get it to hang more consistently then. – C-H-E-F Sep 09 '17 at 10:51

2 Answers2

1

I integrated a left side menu, that operates as a settings screen, and I believe that the:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

And that left side menu were clashing, when I say clashing I mean, when I pop the next view controller, I believe somewhere in the stack that the views got tangled up. So when I push to another view, the app doesn't know rather to use the left side menu or to use the navigation controller without the left side menu...

So instead of allowing the:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

I decide to place this code in my viewwillappear method:

self.navigationController.interactivePopGestureRecognizer.delegate = self;

NSUInteger viewControllerCount = self.navigationController.viewControllers.count;

NSLog(@"viewControllerCount %ld", viewControllerCount);

    if (viewControllerCount == 1)
    {

self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }
    else
    {

self.navigationController.interactivePopGestureRecognizer.enabled = NO;
    }

I placed this code in the initial navigation controller so whenever I push, the left side menu will be on every screen within the app, and then I implemented a back button on each screen so that I can pop the views instead of sliding left, I didn't want to implement the UINAVIGATIONBAR at the top because I need that small piece of screen as well to display everything haha...

I hope this helps anyone in the future that may have the same issues, good luck, happy coding.

C-H-E-F
  • 165
  • 11
0

I had this issue too and what I noticed was that my current view controller was not embedded in a UINavigation controller so on using navigationController?.pushViewController(viewController, animated: true) my current navigationController was null