如何构建 USAToday 类型的应用程序?水平和垂直滚动控制
我正在尝试构建一个类似于 USAToday 的应用程序,即每篇“文章”都是图像和文本的混合,如果它覆盖的范围超过屏幕的大小,用户可以垂直滚动以阅读。水平滚动会显示下一篇文章,依此类推。
每篇文章都应该“启用分页”,以便内容移动就像您在书中翻页一样,无论您是垂直还是水平移动。
我一定已经看过有关滚动和页面导航的所有教程,但我却一片空白。非常感谢任何帮助。
顺便说一句:我已经下载了本教程...
http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
...但是(a)它构建正常,但模拟器只显示毫无特色的黑屏,并且我不知道如何纠正它,并且(b)它只能水平滚动。
I am trying to build an app similar to USAToday i.e. each "article" is a mix of images and text that the user scrolls vertically to read if it covers more than than the size of the screen. Scrolling horizontally brings up the next article and so on.
Each article should have "paging enabled" so that the content moves as if you are turning a page in a book whether you are moving vertically or horizontally.
I must have looked at every tutorial for Scroll and Page navigation, but I am drawing a blank. Any help is much appreciated.
BTW: I have down loaded this tutorial....
http://www.edumobile.org/iphone/iphone-programming-tutorials/pagecontrol-example-in-iphone/
... but (a) it builds ok but simulator only shows a featureless black screen, and I cannot work out how to correct it, and (b) it only scrolls horizontally.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您引用的示例代码很旧,因此我认为自那时起 SDK 中发生了一些变化。我至少能够通过更改 MainWindow.xib 文件来运行代码。我在 Interface Builder 中打开该文件,然后选择窗口,然后在窗口属性检查器中勾选“启动时可见”。然后教程至少会运行并显示颜色。我想你可能会发现它还有更多问题。
当您想要对某些内容进行分页时,真正的技巧是设置滚动视图的内容大小。
这个 StackOverflow 问题提供了一些可以帮助您入门的有用信息。
The sample code that you reference is old so I think something has changed in the SDK since then. I was able to at least get the code to run by changing the MainWindow.xib file. I opened that file in Interface Builder and then selected the Window and then in the Window Attributes Inspector I ticked "Visible at Launch". Then the tutorial would at least run and show the colors. I think you might find that there are more issues with it though.
When you are wanting to page something, the real trick is setting the content size of the scroll view.
This StackOverflow question has some good information that might help you get going.