如何创建无限滚动的UIScrollView? [英] How to create a UIScrollView of infinite scrolling?

查看:118
本文介绍了如何创建无限滚动的UIScrollView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 我有一个大小为320 * 460且内容大小为1024 * 1024的UIScrollView。

  2. 我可以在其中放置25张256 * 256的图像第13张图片显示在
    屏幕的中央,周围有周围的图片。

  3. 当我向任何一侧滑动时,我希望它看起来就像是MapView类。随着新图像出现并显示

我该怎么做?

推荐答案

这很简单&有点棘手......

It's very easy & somewhat tricky...

您无需为ScrollView定义特定大小.....

You don't need to define the specific size for the ScrollView.....

通常我们用来定义....根据Apple的例子

Generally we use to define ....as per the Examples of Apple

//#define SCROLLVIEW_CONTENT_HEIGHT 460

//#define SCROLLVIEW_CONTENT_WIDTH  320

这是没用的...如果你需要无限高度..

which is of no use...if you need the infinite height..

根据添加到ScrollView的对象动态设置ScrollView的高度....

just set the height of the ScrollView dynamically as per the Objects added to the ScrollView....

无需为此设置预定义高度...采取动态高度....

No need to set the predefined height for this...take the dynamic height....

scrollview.contentSize = CGSizeMake(320, txtView.contentSize.height+450);
 CGPoint topOffset = CGPointMake(0,0);
 [scrollview setContentOffset:topOffset animated:YES];

希望这对你有用..

祝你好运:)

这篇关于如何创建无限滚动的UIScrollView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆