简体   繁体   English

UIScrollView不在iOS 7 StoryBoard中滚动

[英]UIScrollView Not Scrolling In iOS 7 StoryBoard

I am trying to add a UILabel along with a UIWebView together in a view controller and want them to scroll together. 我试图在视图控制器中一起添加UILabel和UIWebView,并希望它们一起滚动。 So to accomplish that, i have added a UIScrollView behind these two views but the UIScrollView is just not scrolling. 所以为了实现这一点,我在这两个视图后面添加了一个UIScrollView,但UIScrollView只是不滚动。 I am using Storyboard and iOS 7 SDK. 我正在使用Storyboard和iOS 7 SDK。

UIScrollView中

I have seen many questions but they are not of much help. 我见过很多问题,但是没有多大帮助。 Some are suggesting that i should disable the AutoLayout that i cannot do due to the requirements of my project. 有些人建议我应该禁用由于项目要求而无法执行的AutoLayout。 What else can i do to make it work? 我还能做些什么才能让它发挥作用? Thanks! 谢谢!

According to Apple's documentation, you shouldn't use UIWebView inside UIScrollView. 根据Apple的文档,您不应该在UIS​​crollView中使用UIWebView。 What you can do is to add your UILabels and UIWebView inside aother UIView and then add this UIview inside the UIScrollView. 你可以做的是在另一个UIView中添加你的UILabels和UIWebView,然后在UIScrollView中添加这个UIview。

Secondly, you have to set the contentSize of the UIScrollView in order for it to work. 其次,您必须设置UIScrollView的contentSize才能使其正常工作。

You also have to disable the scrolling of UIWebView that is embeded inside the UIScrollView. 您还必须禁用UIScrollView中嵌入的UIWebView的滚动。

Still if your problem is not solved. 如果你的问题没有解决。 It is better to just turn of AutoLayout. 最好只关闭AutoLayout。 I have had the same issue and i wasnt able to solve it without disable the AutoLayout. 我有同样的问题,我无法解决它而不禁用AutoLayout。

The documentation for UIWebView states: UIWebView的文档说明:

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. 重要提示:您不应在UIScrollView对象中嵌入UIWebView或UITableView对象。 If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled. 如果这样做,可能会导致意外行为,因为两个对象的触摸事件可能混淆和错误处理。

You need to wrap the label and web view in a regular UIView. 您需要将标签和Web视图包装在常规UIView中。 Add the regular view to the scroll view. 将常规视图添加到滚动视图。

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

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