5

我想为一个节日制作一个阵容。您可以在下面看到我想要实现的目标。 在此处输入图像描述

您可以在各个方向滚动,水平 - 垂直和从左到右角(不知道英文中的正确单词)。如果您在一个部分滚动,则其他部分应该随之滚动。

我的问题是知道你怎么能做到这一点?我正在寻找几天来让这个工作,但没有找到一个好的解决方案......

4

2 回答 2

5

UITableView 中的行不会在 UITableView 内滚动。一种解决方案是使用 UIScrollView,然后在里面添加 UITableView。此 UIScrollView 将具有与您的 UITableView 现在相同的大小,但 UIScrollView contentSize 属性将具有相同的高度但它会具有更大的宽度。

在此处输入图像描述

UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(x, x, x, x) style:...]

[scrollView addSubview:tableView];

// Set the size of your table to be the size of it's contents 
// (since the outer scroll view will handle the scrolling).
CGRect tableFrame = tableView.frame;
tableFrame.size.height = tableView.contentSize.height;
tableFrame.size.width = tableView.contentSize.width; // if you would allow horiz scrolling
tableView.frame = tableFrame;

// Set the content size of your scroll view to be the content size of your 
// table view + whatever else you have in the scroll view.
// For the purposes of this example, I'm assuming the table view is in there alone.
scrollView.contentSize = tableView.contentSize;
于 2013-05-08T09:26:56.237 回答
1

为了更好地理解 UITableView 滚动,您可以点击这两个链接

水平滚动表格

垂直表格滚动

我希望它可以帮助您更好地理解和熟悉 UITableViewDelegate。谢谢

于 2013-05-08T10:03:30.020 回答