问题
I am trying to create a verticalTableView that has a horizontalTableView inside each verticalTableViewCell that can scroll horizontally (same concept as the 'Pulse' app). And I have found a number of tutorials (two examples below), but they are all in the days of XIBs. 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. This person has managed to implement the protocols for a tableView using a UITableViewCell class, question is how? And does it matter that the tableView that contains the dynamic tableView is static?
dynamic UITableView in static UITableViewCell
回答1:
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.
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
in that method, use this.
self.transform = CGAffineTransformMakeRotation(M_PI * 0.5);
回答2:
Thanks to @christoph, I finally figured it out. See sample code in his question.
dynamic UITableView in static UITableViewCell
来源:https://stackoverflow.com/questions/10779032/how-to-create-a-uitableview-that-can-scroll-horizontally