This seems kind of odd to me, but I'm new to iOS so something obvious might be going on that I am unaware of (I asterisk the part that is the inconsistency):
- I have two tabs: Tab1 and Tab2
- Tab1 is a basic view.
- Tab2 is a Master-Detail type design pattern, with a UITableViewController as the Master tab, and a Scroll View (nested in a UIViewController) as the Detail tab.
- Whenever I click a cell in Tab2's Master view, it takes me to the Detail view, as expected.
- If I scroll down in the Detail view, then click Tab1 and then click Tab2, it reloads the Detail view where it left off (scrolled down).*
- However, right after I do this, if I click Tab1 and then click Tab2 (the same exact thing as I did in the last step), it reloads the Detail view from the top of the page.*
I told it to reload the Detail view from the top of the page with this code, which is inside the Class for the view controller that contains the scroll view:
-(void)viewDidAppear:(BOOL)animated{
[self.scrollView setContentOffset:CGPointMake(self.scrollView.contentOffset.x, 0) animated:NO];
[self.scrollView setScrollEnabled:YES];
[super viewDidAppear:animated];
}
I just found it really weird that switching back and forth between tabs the first time (step 5) didn't show the scroll view from the top of the screen, but switching back and forth between tabs the second time (step 6) did show the scroll view from the top of the screen.
Any idea of what could be causing it? Are tabs are loaded by different methods when reloading them more than once or something?
Any suggestions will be appreciated! Thanks!