简体   繁体   English

IOS UIScrollView不需要的弹跳

[英]IOS UIScrollView Unwanted Bouncing

Hey so I am using the standard design template to implement swipe navigation on a page. 嘿所以我使用标准设计模板在页面上实现滑动导航。 I have a main view controller that holds the center view and two side views. 我有一个主视图控制器,可以保存中心视图和两个侧视图。 The center view is contained in a UIScrollView as to allows the user to scroll up and down. 中心视图包含在UIScrollView中,以允许用户向上和向下滚动。 The right view is a table in which each cell links to static content. 右视图是一个表,其中每个单元格链接到静态内容。 When I move to the page that has the static content and then back to the center view, the scroll view on the center view glitches and allows for "bouncing" in horizontally plane which messes up my swipe functionality. 当我移动到具有静态内容然后返回到中心视图的页面时,中心视图上的滚动视图会出现故障,并允许在水平平面中“弹跳”,这会影响我的滑动功能。 Is there a way to properly go back to the center view or programatically disable all scroll and bounce functionality in the horizontal plane? 有没有办法正确返回到中心视图或以编程方式禁用水平平面中的所有滚动和反弹功能?

to disable bounce use this -> scrollView.bounces = NO; 禁用弹跳使用此 - > scrollView.bounces = NO; to disable horizontal scrolling set content size of scrollview like this -> 禁用水平滚动设置scrollview的内容大小,如下所示 - >

float sizeOfContent = 0;
UIView *lLast = [scrollView.subviews lastObject];
NSInteger wd = lLast.frame.origin.y;
NSInteger ht = lLast.frame.size.height;

sizeOfContent = wd+ht;

scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, sizeOfContent);

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

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