How to use UIScrollView to switch between UIViews

泪湿孤枕 提交于 2019-12-05 05:49:23

问题


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.


回答1:


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.

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




回答2:


I haven't done that, but I saw one example at the app development center. I'm adding the corresponding link:

http://developer.apple.com/iphone/library/samplecode/Scrolling/index.html#//apple_ref/doc/uid/DTS40008023

I hope it helps

Regards Alejandra :)




回答3:


Have a look at the Page Control sample. This uses the UIScrollView paging functionality to do horizontal scrolling between multiple UIView pages.

This demo also has a UIPageControl that updates as you flick between the horizontally scrolled views.



来源:https://stackoverflow.com/questions/1943393/how-to-use-uiscrollview-to-switch-between-uiviews

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!