I’m switching controllers via my navigation controller. When my app first loads the Appointment screen will scrollsToTop just fine. Once I switch controllers to Customers with
CustomerViewController *customers = [self.storyboard instantiateViewControllerWithIdentifier:@"CustomerViewController"];
[self.navController.view removeFromSuperview];
self.navController = [[UINavigationController alloc] initWithRootViewController:customers];
self.navController.view.frame = self.contentView.bounds;
[self.contentView addSubview:self.navController.view];
it stops working. Then switching back to my Appointments controller with
AppointmentViewController *appointments = [self.storyboard instantiateViewControllerWithIdentifier:@"AppointmentViewController"];
[self.navController.view removeFromSuperview];
self.navController = [[UINavigationController alloc] initWithRootViewController:appointments];
self.navController.view.frame = self.contentView.bounds;
[self.contentView addSubview:self.navController.view];
and then clicking the status bar the Appointments no longer scrolls to top. I have scrollsToTop set to YES in all of my controllers that load so they should be scrolling to the top. Anyone know why this stops working when I switch controllers then switch back?
EDIT:
I have my RootViewController which is my side menu (blue menu) and my AppointmentViewController which is the right side view.
.
The above code is in my RootViewController to determine which view should be placed on top.
You’re not removing the old
self.navControllerfrom yourcontentView.