UIScrollView contentOffset在推送另一个视图之后更改 [英] UIScrollView contentOffset change after another view pushed

查看:329
本文介绍了UIScrollView contentOffset在推送另一个视图之后更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Interface Builder中有一个 UIViewController ,并且在中添加了一个 UIScrollView UIView 。它具有等于0.0的 contentOffset 属性,但是当我将 UIScrollView 滚动到底部并推动另一个视图 contentOffset 更改。



NSLog

  //查看刚刚加载的
2013-09-09 16:19:27.455 my_app [24588:907]滚动视图内容偏移量为0.000000

//我们从另一个视图返回
2013-09-09 16:19:30.957 my_app [24588:907]滚动视图内容偏移量为108.000000

这种行为的原因是什么?我刚刚在IB中添加了一个 UIScrollView ,在代码中什么也没做。



scrollView的 contentHeight 大于 self.view.height

解决方案

请参阅我的回答类似的问题。



您需要设置scrollview的 viewWillAppear: viewWillDisappear:适当地在 contentOffset p>

另请参阅:




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 gives me the following values:

//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

What's the reason of this behaviour? I've just added a UIScrollView in IB and did nothing in code at all.

The contentHeight of the scrollView is bigger than self.view.height. The frame of the scrollView stays the same.

解决方案

See my answer to a similar question.

You need to set the scrollview's contentOffset appropriately in viewWillAppear: and viewWillDisappear:.

Also, see this:

这篇关于UIScrollView contentOffset在推送另一个视图之后更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆