问题描述
我在 Interface Builder 中有一个 UIViewController,我在 UIView 中添加了一个 UIScrollView.它的 contentOffset 属性等于 0.0,但是当我将 UIScrollView 滚动到最底部并推送另一个视图时,contentOffset 会发生变化.
I have a UIViewController in Interface Builder, and I add a UIScrollView to the UIView. It has a contentOffset property equal to 0.0, but when I scroll the UIScrollView to the very bottom and push another view the contentOffset changes.
NSLog 给了我以下值:
//View just loaded
2013-09-09 16:19:27.455 my_app[24588:907] Scroll View content offset is 0.000000
//We came back from another view
2013-09-09 16:19:30.957 my_app[24588:907] Scroll View content offset is 108.000000
这种行为的原因是什么?我刚刚在 IB 中添加了一个 UIScrollView 并且在代码中什么也没做.
What's the reason of this behaviour? I've just added a UIScrollView in IB and did nothing in code at all.
scrollView的contentHeight大于self.view.height.scrollView 的 frame 保持不变.
The contentHeight of the scrollView is bigger than self.view.height. The frame of the scrollView stays the same.
推荐答案
查看我的回答类似的问题.
您需要在 viewWillAppear: 和 viewWillDisappear: 中适当地设置滚动视图的 contentOffset.
You need to set the scrollview's contentOffset appropriately in viewWillAppear: and viewWillDisappear:.
另外,请参阅:
- 这个答案问题UIScrollView 弹回 UIViewController 后原点发生变化.
- 这个相关问题,UIScrollview 自动布局问题.
这篇关于推送另一个视图后 UIScrollView contentOffset 更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)