本文介绍了如何使用UIScrollView在UIViews之间切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用多个子视图构建多个 UIViews ,并使用 UIScrollView 在它们之间切换?我很感激能上传一些代码的人。我是iPhone的完整菜鸟。

How would I build multiple UIViews with multiple subviews and switch between them using a UIScrollView? I would appreciate anyone who can upload some code. I am a complete noob withe the iPhone.

推荐答案

我会在UIScrollView中平铺UIViews,然后实现某种分页或快照机制。从滚动视图中收听相应的通知,然后每当滚动完成时,只需以编程方式将滚动视图与您平铺的UIViews之一的边界对齐。

I would "tile" the UIViews in the UIScrollView, then implement some kind of paging or "snap-to" mechanism. Listen on the appropriate notifications from the scroll view, then whenever scrolling finishes, just programmatically align the scroll view to the boundaries of one of your tiled UIViews.

或者,请查看使用实现此类行为Weather应用程序就是一个很好的例子。

Alternately, look at using UIPageControl to implement this kind of behavior. The Weather app is a good example.

这篇关于如何使用UIScrollView在UIViews之间切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-18 00:43