xcode 在 UITableView 中水平滚动 - Swift 3,iOS
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/44714460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Scroll horizontally in UITableView - Swift 3, iOS
提问by Brewski
I need to horizontally scroll through a list of thumbnails at the bottom of the screen that shows all the user's recently taken photos / videos.
我需要水平滚动屏幕底部的缩略图列表,其中显示了用户最近拍摄的所有照片/视频。
I created a UIScrollViewwith a UITableviewinside of it.
我创建了一个UIScrollView,里面有一个UITableview。
Is this the correct approach because I can't seem to find an override method in its superclass for scrolling direction? Most of the topics I can find online deals with putting a UIscrollview inside a TableCell, which will not work for my specific application?
这是正确的方法,因为我似乎无法在其超类中找到用于滚动方向的覆盖方法吗?我可以在网上找到的大多数主题都涉及将 UIscrollview 放入 TableCell 中,这对我的特定应用程序不起作用?
The hierarchy is:
层次结构是:
View > Scroll View> Table View > Table Cel> Content > PhotoThumbnail
视图 >滚动视图> 表格视图 >表格单元> 内容 >照片缩略图
回答by Krishna Kumar
I am not really sure why do you want to use UITableView
for horizontal scrolling which lay out there cells in vertical manner. If you want horizontal scrolling I would recommend using UICollectionView
where cells can be added horizontally or vertically or both.
Still if you want tableview to be scrollable in horizontal direction I would suggest you to check this project to get inspiration or using it.
我不太确定你为什么要UITableView
用于水平滚动,以垂直方式布置单元格。如果您想要水平滚动,我建议使用UICollectionView
可以水平或垂直或两者添加单元格的位置。尽管如此,如果您希望 tableview 在水平方向上可滚动,我建议您检查此项目以获取灵感或使用它。
回答by Aravind A R
Instead of using UITableView you can use UICollectionView to achieve the desired result i.e, horizontally scrollable cells with imageView and other elements that you need.
除了使用 UITableView,您还可以使用 UICollectionView 来实现所需的结果,即使用 imageView 和您需要的其他元素水平滚动单元格。