简体   繁体   English

如何创建一个可以水平滚动的UITableView?

[英]How to create a UITableView that can scroll horizontally?

I am trying to create a verticalTableView that has a horizontalTableView inside each verticalTableViewCell that can scroll horizontally (same concept as the 'Pulse' app). 我正在尝试创建一个verticalTableView,每个verticalTableViewCell内都有一个horticalTableView,它可以水平滚动(与“ Pulse”应用程序具有相同的概念)。 And I have found a number of tutorials (two examples below), but they are all in the days of XIBs. 而且我发现了许多教程(下面有两个示例),但是它们都是在XIB时代出现的。 Can anyone explain how to do it/give me a link to a tutorial on how to do the same with a Storyboard instead? 谁能解释如何做/给我一个有关如何使用情节提要的教程的链接吗?

First Tutorial 第一教程

Second Tutorial 第二教程

Update: I have since found another question on SO that was answered by the same person that asked the question. 更新:此后,我在SO上发现了另一个问题,问这个问题的同一个人回答了这个问题。 This person has managed to implement the protocols for a tableView using a UITableViewCell class, question is how? 这个人已经设法使用UITableViewCell类实现tableView的协议,问题是如何? And does it matter that the tableView that contains the dynamic tableView is static? 包含动态tableView的tableView是静态的是否重要?

dynamic UITableView in static UITableViewCell 静态UITableViewCell中的动态UITableView

Use the below part of code to create the required table. 使用下面的代码部分创建所需的表。

    UITableView *horizontalTable = [[UITableView alloc] init];
    [horizontalTable setDelegate:self];
    [horizontalTable setDataSource:self];
    horizontalTable.transform = CGAffineTransformMakeRotation(-M_PI * 0.5);
    horizontalTable.autoresizesSubviews=NO;
 frame =CGRectMake(140, 0 , 642, 85);
//frame is important this has to be set accordingly. if we did not set it properly, tableview will not appear some times in the view
[self.view addSubview:customTable];

and in the custom cell's CustomCell Class, we find the below method. 在自定义单元格的CustomCell类中,我们找到以下方法。

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier

in that method, use this. 在这种方法中,使用它。

 self.transform = CGAffineTransformMakeRotation(M_PI * 0.5);

Thanks to @christoph, I finally figured it out. 感谢@christoph,我终于弄明白了。 See sample code in his question. 请参阅他的问题中的示例代码。

dynamic UITableView in static UITableViewCell 静态UITableViewCell中的动态UITableView

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM