简体   繁体   English

如何增加UIScroll视图的滚动区域

[英]How to increasing scrolling area of UIScroll view

I have a scroll view with 5 images and some text views. 我有一个包含5张图片和一些文本视图的滚动视图。 It scrolls horizontally. 它水平滚动。

Now, when I scroll the content of the scroll view moves to an area. 现在,当我滚动时,滚动视图的内容将移动到一个区域。
How can I increase this limit? 如何增加此限制?

I mean: I need to scroll more on single scrolling. 我的意思是:我需要在单滚动上滚动更多。

I have tried with increasing the contentSize . 我尝试增加contentSize
It does not have the desired result: only the content of scroll view got increased. 它没有理想的结果:仅滚动视图的内容增加了。

尝试使用代码。

[scrollView setDecelerationRate:UIScrollViewDecelerationRateFast];

您可以在scrollview委托方法中设置scrollview的contentoffset属性

- (void)scrollViewDidScroll:(UIScrollView *)scrollView

You can try it on viewDidLoad method :: scr.contentSize = CGSizeMake(320, 500); 您可以在viewDidLoad方法上尝试:: scr.contentSize = CGSizeMake(320, 500);
or whatever you want height. 或任何你想要的高度。

Otherwise you can set it dynamically after all images & textviews will be loaded. 否则,可以在加载所有图像和文本视图之后动态设置它。

eg. 例如。 float h = [imagesCount * imageHeight] + [textVwCount *textVwHeight] + 100;

then set to scr.contentSize = CGSizeMake(320, h); 然后设置为scr.contentSize = CGSizeMake(320, h);

But keep in mind, always put height's value greater than actual size for ScrollView control. 但是请记住,对于ScrollView控件,始终将height的值设置为大于实际大小。

Hopefully it will help you. 希望它将对您有所帮助。

Thanks. 谢谢。

Try this 尝试这个

use UIScrollviewdelegate in .h file 在.h文件中使用UIScrollviewdelegate

and then use 然后使用

-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{

in that function use 在该功能中使用

[scrollview setContentOffset:CGPointMake(scrollview.frame.origin.x+(value u want to scroll more) , 0) animated:TRUE];

The above code will allow ur scrollview to scroll more 上面的代码将使您的scrollview滚动更多

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

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