如何创建无限滚动的 UIScrollView?
- 作者: 老婆孩子热炕头儿
- 来源: 51数据库
- 2022-10-20
问题描述
- 我有一个大小为 320*460 且内容大小为 1024*1024 的 UIScrollView.
- 我可以在其中放置 25 张 256*256 的图片,其中第 13 张图片显示在图片的中心当它加载周围的一些图片时屏幕.
- 当我滑动到任何一侧时,我希望它看起来就像 mapView.带有新图像出现和显示.
我该怎么做?
推荐答案
很简单&有点棘手...
It's very easy & somewhat tricky...
你不需要为 ScrollView 定义具体的大小.....
You don't need to define the specific size for the ScrollView.....
一般我们用...来定义...根据苹果的例子
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];
希望这肯定对你有用..
Hope this will surely work for you..
祝你好运:)
推荐阅读
热点文章
检查拆分键盘
0
带有“上一个"的工具栏和“下一个"用于键盘输入AccessoryView
0
Activity 启动时显示软键盘
0
UIWebView 键盘 - 摆脱“上一个/下一个/完成"酒吧
0
在 iOS7 中边缘滑动时,使键盘与 UIView 同步动画
0
我的 iOS 应用程序中的键盘在 iPhone 6 上太高了.如何在 XCode 中调整键盘的分辨率?
0
android:inputType="textEmailAddress";- '@' 键和 '.com' 键?
0
禁用 iPhone 中键盘的方向
0
Android 2.3 模拟器上的印地语键盘问题
0
keyDown 没有被调用
0
