简体   繁体   English

UIScrollView不在ios6中滚动

[英]UIScrollView not scrolling in ios6

In my UIViewController I have a UIScrollView and UIView . 在我的UIViewController我有一个UIScrollViewUIView These are two different view, means UIView is not inside UIScrollView . 这是两个不同的视图,意味着UIView不在UIScrollView I have different view on scrollview that i am setting programmatically and increasing contentSize . 我对scrollview有不同的看法,我正在以编程方式设置并增加contentSize And this UIView is hidden, i am showing is sometimes. 而这个UIView是隐藏的,我有时会表现出来。 The problem is that when i hide this UIView , that UIScrollView stops scrolling. 问题是,当我隐藏这个UIView时, UIScrollView停止滚动。

Why this happening? 为什么会这样?

I have set all leading edges to superview of both. 我已将所有前沿设置为两者的超视图。 Does it matter? 有关系吗? Please guide me. 请指导我。

Hi all, I am sharing the image of my ViewController Scene 大家好,我正在分享我的ViewController Scene的图像 在此输入图像描述

I am using auto layout (iOS6). 我正在使用自动布局(iOS6)。 Scroll View ContentSize is (768,1400) which i am setting in ViewDidAppear . Scroll View ContentSize是(768,1400)我在ViewDidAppear设置。 The View below Scroll View is hidden and Scroll View is scrolling without any problem. 隐藏Scroll View View下方的Scroll ViewScroll View滚动没有任何问题。

Now if i show and hide the View , the Scroll View locks, its not scrollable now. 现在如果我显示并隐藏ViewScroll View锁定,它现在不可滚动。 That is problem i am facing. 这是我面临的问题。 I am not doing anything in code more than setting content size. 我没有在代码中做任何事情而不是设置内容大小。 If you need any other information, please tell me. 如果您需要任何其他信息,请告诉我。

The contentSize in iOS 6 "auto-sizes" itself with auto layout. iOS 6中的contentSize “自动调整”自动布局。 This means you cannot set the contentSize . 这意味着您无法设置contentSize There are hacks that suggest setting it in the viewDidAppear call, but I would avoid this. 有些黑客建议在viewDidAppear调用中设置它,但我会避免这种情况。 If you read the iOS 6 release notes (search for UIScrollView on the page) it gives you a couple solutions. 如果您阅读iOS 6发行说明 (在页面上搜索UIScrollView ),它会为您提供一些解决方案。 One of them involve the translatesAutoresizingMaskIntoConstraints property. 其中一个涉及translatesAutoresizingMaskIntoConstraints属性。

Remove all your code related to sizing the scrollview content size. 删除与调整scrollview内容大小相关的所有代码。 Autolayout uses this while you are scrolling now. 当你滚动时,Autolayout会使用它。 After you do this add the following code 执行此操作后,添加以下代码

// Add 200 points to the bottom of the scroll view
[self.scrollView setContentInset:UIEdgeInsetsMake(0, 0, 200, 0)];
self.scrollView.translatesAutoresizingMaskIntoConstraints= NO;

Without any code, I'll hazard a guess... 没有任何代码,我会冒险猜测......

This would be typical in a case if your contentSize doesn't exceed the size of your UIScrollView . 如果您的contentSize不超过UIScrollView的大小,这将是典型情况。 If you were to, say, hide your view, then change the size of your scroll view and your scroll view exceeds or is equal to your contentSize , then you will not have anything to scroll. 如果您要隐藏视图,然后更改滚动视图的大小并且滚动视图超出或等于您的contentSize ,那么您将无法滚动任何内容。

Another possibility is if you have disabled user interaction. 另一种可能性是您已禁用用户交互。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM