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

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

问题描述

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

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

用户界面的行为如下:


  1. 在初始状态下,表格单元格显示一个标签和一些文本,圆形项目从右侧弹出

  2. 如果用户从右向左滑动,标签和文本将淡出,水平列表(在单元格内)占据它的位置






我考虑过使用TableView和 dequeueReusableCellWithIdentifier 并创建一个原型单元格,但后来我需要记住列表水平位置和init正确处理 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.

问:什么您将使用布局来实现此目标,任何输入/ tut orial将不胜感激

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

推荐答案

使用 UITableView 并添加 UICollectionView 到您的可重用tableView单元格。 UICollectionView 的工作方式类似于 UITableView ,因为items(如单元格)只有当它们出现时才可重复使用并实例化在屏幕上。我快速搜索了谷歌搜索教程,并在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 - 如何使用水平滚动列表创建TabelView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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