ios UIScrollView有一个错误的默认contentOffset - swift [英] ios UIScrollView have a bad default contentOffset - swift

查看:768
本文介绍了ios UIScrollView有一个错误的默认contentOffset - swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在主视图中的ScrollView内有一个View

I have a View inside a ScrollView inside my main View

问题是我的scrollView有一个错误的默认contentOffset。
他的值是(0,-64)的肖像

The problem is that my scrollView have a bad default contentOffset. His value is (0, -64) in portrait

Apple doc说

The Apple doc says


默认值为CGPointZero。

The default value is CGPointZero.

我将此代码放在我的控制器上以临时处理它:

I put this code on my controller to temporary handle it :

dispatch_async(dispatch_get_main_queue(), {
  self.scrollView.setContentOffset(CGPointZero, animated:false)
})

为什么我的contentOffset没有良好的默认值?

Why my contentOffset have not the good default value ?

推荐答案

视图插入可能是一个问题。

It's probably an issue with the view insets.

在视图控制器的XIB / Storyboard上,确保取消选中调整滚动视图插图

On your XIB/Storyboard for your view controller, make sure to uncheck the Adjust Scroll View Insets

或在您的代码中添加 self.automaticallyAdjustsScrollViewInsets = false

这篇关于ios UIScrollView有一个错误的默认contentOffset - swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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