1
votes

I have a UIScrollView with paging enabled. After I change the view from landscape to portrait (and vice versa) I change the frame size and I want the contents inside to "snap" to the new frame size. Right now the content offset is stuck from the previous frame size. However, when I scroll after a frame change it will snap to the correct offset. I tried to set the content offset after a frame size change but it still wouldn't snap to the new frame. Any ideas on how to accomplish this? Sorry if this is not clear.

1
Have you tried calling setNeedsLayout after changing the frame size?user244343
Yeah I tried that and no luckjohosher

1 Answers

0
votes

Turns out I was just doing my math wrong when trying to setContentOffset.

CGFloat x = (self.thumbnails.pageControl.currentPage * self.thumbnails.scrollView.frame.size.width);
[self.thumbnails.scrollView setContentOffset:CGPointMake(x,0)];