在 iBooks 中重新创建 BookCase
我只是想知道如何在 iPhone 应用程序中实现书柜(例如 iBooks 中的书柜)。
我认为您需要使用 UIScrollView
,但后来我在某处读到您需要使用 UITableView
。是哪一个?!
I just wanted to know how you could implement a bookcase, like in iBooks, into your iPhone app.
I presume you would need to use a UIScrollView
, but then I read somewhere that you need to use a UITableView
. Which is it?!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用其他人已经编写的代码,例如
AQGridView
。You'd use code that others have already written, such as
AQGridView
.我不确定是否有更好的方法,但是您可以创建多个小视图或图像(这些视图或图像代表每本书),然后将这些小视图/图像以线性格式添加到较大视图的子视图中(在每个元素)。然后只需将大视图的背景设置为书架的图像即可。抱歉我不知道更好的方法。
对于上述解决方案,我将使用 UIScrollView。
I'm not sure if there's a better way, but you could create multiple small views or images (these would represent each book) then add these small views/images to the subview of a larger view in a linear format (leaving a space between each element). Then just set the background of your larger view as an image of a bookcase. Sorry I don't know of a better way.
And for the above solution I would use a UIScrollView.
你可以随心所欲地实现它,但在我看来, UITableView 是最简单的(无论如何它都会滚动)。所有的魔力都将发生在您的 UITableViewDataSource 中,您可以在其中决定将哪些书放置在哪一行。
一旦您决定要显示哪些书籍,您将创建一个自定义表格视图单元格来绘制适当的对象。
说实话,虽然这不是一项太难的任务,但要做得正确却需要付出很大的努力。如果您对自定义绘图感到不舒服,那么请准备好花时间学习各种图像/图形 API。
You can implement it anyway you like, but it seems to me that a UITableView would be the easiest (which will scroll anyway). All of the magic will happen in your UITableViewDataSource, which is where you will decide what books are placed on what row.
Once you have decided which books to display you will have create a custom tableview cell that draws the appropriate objects.
To be honest, while not too difficult of a task, it will take a lot of effort to get looking right. If you are not comfortable with custom drawing then be prepared to spend time learning about the various image/graphic APIs.