gpt4 book ai didi

ios - UITableView - 在每个单元格内水平滑动内容

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:18:19 32 4
gpt4 key购买 nike

这是我的第一个原生 iOS 应用...

与 iOS 上的 iTunes 应用程序完全一样,通过具有可以垂直滚动的表格 View ,然后每一行,您可以独立地水平滚动。至少这是我想象它可以工作的方式。

我将如何实现?我想象每个 tableCell 中的 View 可以水平滚动?

任何人都可以阐明这一点以及我可能阅读或尝试做的事情

最佳答案

您可以将 ScrollView 添加到单元格内容 View 中,然后将 ScrollView 的内容大小属性添加到您想要的任何长度。在这里,我将 ScrollView 的宽度设置为 1000,将高度设置为 44(这是 UITableViewCell 的默认大小)。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}

UIScrollView *vwScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
vwScroll.backgroundColor = [UIColor scrollViewTexturedBackgroundColor];
vwScroll.contentSize = CGSizeMake(1000, 44);

[cell.contentView addSubview:vwScroll];

return cell;
}

关于ios - UITableView - 在每个单元格内水平滑动内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15479031/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com