UIScrollView contentOffset is set automatically when switched to foreground
I am developing an iPhone application. I have my code implemented this way:
RootViewController has UIScrollView as its view. Then RootViewController pushes another UIViewController say vc which again has UIScrollView (sv) as its view.
The bounds/frame size of sv开发者_StackOverflow中文版 is (320, 460) and content size is (320, 520). So, sv is now scrollable vertically. Hence, I have set content offset of sv to be (0, 60).
I switch to background using Home button of iPhone and again put my application to Foreground. In this case my sv content offset is set to (0, 0) automatically with animation.
When I tried to override setContentOffset: I noticed that some library call [adjustsIfNeeded], sets content offset to be (0, 0).
Why is this happening?
This was because, my base view of UIViewController was UIScrollView. I changed it to a UIView and then added UIScrollView as its subview. Now, it works fine.
精彩评论