iOS-如何使用水平可滚动列表创建TableView [英] IOS - How to create TableView with horizontal scrollable lists

查看:305
本文介绍了iOS-如何使用水平可滚动列表创建TableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用可滚动的水平项目(项目数量未知)来实现表格视图,如下图所示:

I'm trying to implement a table view with scrollable horizontal items (with unknown number of items) like the illustration below:

用户界面的行为应如下:

The UI should behave like so:

  1. 在初始状态下,表格单元格显示一个标签和一些文本,并且圆圈项目从右侧弹出
  2. 如果用户从右向左滑动,标签和文本将淡出,并且水平列表(位于单元格内部)将取代其位置


我曾考虑过使用TableView和dequeueReusableCellWithIdentifier并创建一个原型单元,但是随后我需要记住列表的水平位置并在cellForRowAtIndexPath上正确地初始化该单元,这可能会影响性能.


I thought about using TableView and dequeueReusableCellWithIdentifier and creating a prototype cell, but then I need to remember the list horizontal position and init the cell properly on cellForRowAtIndexPath and that will probably affect performance.

问:您将使用哪种布局来实现此目标,任何输入/教程都将受到赞赏

Q: What layout would you use in order to achieve this goal, any input / tutorial would be appreciated

推荐答案

使用UITableView并将UICollectionView添加到可重用的tableView单元格中. UICollectionView的作用与UITableView相似,因为项目"(如单元格)仅在它们出现在屏幕上时才可重用和实例化.我在Google上做了一个快速的Google搜索教程,发现 UITableViewCell中的UICollectionView .检查一下有关设计的其他StackOverflow问题,您应该很聪明.

Use a UITableView and add a UICollectionView to your reusable tableView cell. UICollectionView works similar to UITableView in that the "items" (like cells) are reusable and instantiated only when they will appear on screen. I did a quick google search for tutorials and found UICollectionView in UITableViewCell. Check that out and a few other StackOverflow questions regarding design and you should be golden.

这篇关于iOS-如何使用水平可滚动列表创建TableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆