Closed inPhilly closed 9 years ago
I believe the error is in the initial method: observeValueForKeyPath:ofObject:change:context: but I am having a hard time figuring out how to fix it.
I tried using the parallax-header merge branch and that does not fix the problem.
Hi,
yes it's a known issue. It happens when you are on the last page, this is because a UIScrollView change the contentoffset when you rotate due to the new contentsize. The fix might be somewhere in the MXPagerView's properties. I will have a look.
I think it happens not just when you are on the last page, but whenever the frame of the view changes. In both the cases I am describing (1. expanding the detail View in a UISplitViewController to fit the whole page and 2. rotating the device) the entire view frame changes. I think the fix will involve differentiating between the contentOffset changing due to a gesture vs. contentOffset changing due to a frame change. When the contentOffset changes due to a gesture, a new segment index may be selected. When the contentOffset changes due to a frame change, the appropriate new contentOffset should be calculated based on the currently selected index. I looked at the code and I do not see offhand how I could do this. But hopefully this can help you solve the bug and if I do see a solution, I will let you know.
Hi @maxep. Have you had any chance to take a look at this, or do you expect that you will soon?
Sorry, I do not have time to work on it at the moment. I will get back to it asap..
Do you think you will have any time to work on this? I have wasted so much time and I simply cannot get it solved. I'm so sorry to ask, but I am desperate!
Hi maxep. Do you think I should give up on this fix coming at any time? Again, I wish I could contribute. It is beyond my knowledge.
Hi @mommyme
I cannot find a quick fix for this. I know that I have to redesign the MXPagerView to have a better behavior but I can do it any time soon, I'm very busy at the moment. I can't assure you when but this has to be fixed.
Hi @mommyme I thought about it yesterday and I found a solution. can you try the latest code? but be careful, I have merged the MXSegmentedPager with the ParallaxHeader category, which mean you have to change #import "MXSegmentedPager+ParallaxHeader.h" to #import "MXSegmentedPager.h". Please fill up an issue if you have any regression.
The contentOffset changes when the iPad rotates or when the detail view of a UISplitviewController is expanded to fill the width of the screen. The change in contentOffset sets off this sequence
-[MXPagerView observeValueForKeyPath:ofObject:change:context:] -[MXPagerView didScrollFromPosition:ToPosition:] -[MXPagerView setIndex:] -[MXSegmentedPager pagerView:didMoveToPageAtIndex:]
which calls: [self.segmentedControl setSelectedSegmentIndex:index animated:NO];
So when I rotate the iPad or expand the detailView of a UISplitviewController to fill the screen, a different segment of the segmentedControl is often selected (sometimes it does not switch, but in many/most cases it does).