简体   繁体   English

iOS 8 AutoLayout滚动视图在iPhone 6 plus上水平滚动

[英]iOS 8 AutoLayout scrollview scrolls horizontally on iPhone 6 plus

I do have an App for iOS and while adapting all the UI to auto layout an size classes to support the new iPhone 6 and iPhone 6 plus i faced a weird issue... al my scrolls view work fine in iPhone 4s, 5, 5s and 6... in iPhone 6 plus they are not scrolling only vertically but also horizontally... like if the content size of the scroll view where a couple of pixel wider than the view itself (so it move horizontally of a couple of pixel and then it bounce). 我有一个适用于iOS的应用程序,同时调整所有UI以自动布局大小类以支持新的iPhone 6和iPhone 6加我面临一个奇怪的问题...我的滚动视图在iPhone 4s,5,5s工作正常6 ...在iPhone 6中它们不是垂直滚动而是水平滚动...就像滚动视图的内容大小,其中几个像素比视图本身宽(所以它水平移动几个像素)然后它反弹)。 I do not understand why is this happening... 我不明白为什么会这样......

I finally found a proper way to let it work... I did it this way: 我终于找到了让它运作的正确方法......我这样做了:

View hierarchy: 查看层次结构
- UIView (Main view) - UIScrollView (which I wan of the same exact size of the Main view) - UIView (Container View containing all the stuff to be displayed in the scroll view) - UIView(主视图) - UIScrollView(我的主视图大小与我相同) - UIView(容器视图包含要在滚动视图中显示的所有内容)

Constraints: 约束:

Containar View: 包含视图:
- width equals to the one of the Main View - 0 leadin, trailing, top and bottom margin with superview (which is the Scroll View) - 宽度等于主视图 - 0 leadin,尾随,顶部和底部边距与superview(这是滚动视图)之一

UIScrollView: UIScrollView中:
- width equals to the one of the Main View - 宽度等于主视图之一
- center view on X axis horizontally (center X) - 水平X轴上的中心视图(中心X)
- 0 top an bottom margin with superview - 0超出底部边距与superview

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

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