UITableView-我可以跨多个行还是可以使用嵌套的UITableView? [英] UITableView - Can I Span Multiple Rows or use a Nested UITableView?

查看:31
本文介绍了UITableView-我可以跨多个行还是可以使用嵌套的UITableView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我基本上是在尝试实现以下可滚动的布局,并正在寻求有关实现此效果的最佳方法的一些建议...

I'm basically trying to achieve the following scrollable layout and am looking for some suggestions as to the best way to achieve it...

可能的解决方案是...

Potential solutions might be...

我考虑过在具有行A1,A2和A行的父UITableView中将单个行的所有"A"组件部分包含在其中.子UITableView中为A3,但不确定是否可行?

I have considered having all of the 'A' componenets part of a single row in a parent UITableView with rows A1, A2 & A3 in a child UITableView but I'm not sure if this is possible?

我也不确定是否可以有一个UITableView但在多个行之间具有区域(例如,您可以在HTML表中进行操作).然后,区域A,B,C等可以只是跨越各自行的视图.

I am also unsure if its possible to have a single UITableView but have areas within span multiple rows (like you can do in a HTML table for example). Then area A, B, C etc can just be views that span their respective rows.

任何建议表示赞赏.

推荐答案

感谢所有答复,我对它们进行了投票,因为它们很有帮助,但是由于我实际上实施了一个完整的方法,因此我没有接受它们作为答案与建议在UITableView下面结合使用UIScrollView的解决方案不同的解决方案,如下所示.请注意,没有嵌套或跨越操作.

Thanks for all the replies, I've up-voted them because they were helpful however I haven't accepted them as the answer since I actually implemented a completely different solution to those suggested using a combination of a UIScrollView underneath a UITableView as below. Note there's no nesting or spanning going on.

UITableView的委托设置为UIViewController.未设置UIScrollView的委托.

The UITableView's delegate is set to be the UIViewController. The UIScrollView's delegate is NOT set.

当用户滚动UITableView时,将触发其 scrollViewDidScroll 方法,并且我可以通过以下代码手动滚动相同数量的UIScrollView ...

When the user scrolls the UITableView its scrollViewDidScroll method is fired and I am able to scroll the UIScrollView the same amount manually in code as follows...

- (void)scrollViewDidScroll:(UIScrollView *)tableView
{
    [self.scrollView setContentOffset:tableView.contentOffset animated:YES];
}

当页面加载元素在A,B,C等中的位置以及滚动视图的确切高度时,我必须有点聪明(用代码计算),以便它与UITableView匹配.

I have to be a bit clever to calculate (in code) when the page loads the position of the elements in A, B, C etc and the exact height of the scroll view so it matches the UITableView.

由于我为A1,A2,B2,C3等使用了标准的UITableView,因此当用户选择一行并仍然免费获得标准的UITableView突出显示时,我可以轻松地控制操作.

Since I am using a standard UITableView for A1, A2, B2, C3 etc I am able to easily control the action when the user selects a row and still get the standard UITableView highlighting for free.

缺点

在UIScrollView上滑动/滚动不起作用,您必须在UITableView上滚动.我也许可以通过在UIScrollView上实现一个委托并对它自己的 scrollViewDidScroll 方法做出反应来滚动UITableView来克服这个问题,但是我还没有尝试过,我希望它们会成为问题,因为两者方法会同时触发.

Swiping/scrolling on the UIScrollView has no effect you have to scroll on the UITableView. I might be able to overcome this by implementing a delegate on the UIScrollView and reacting to its own scrollViewDidScroll method to scroll the UITableView but I've yet to try this and I expect they'll be problems since both methods would be firing at the same time.

触摸/点击UIScrollView无效.这可以满足我的需求,但是如果我想执行一些操作,可以使用之前完成的UITapGestureRecognizer.例如

Touching/tapping the UIScrollView has no effect. This is fine for my needs however if I wanted to perform some action I could use a UITapGestureRecognizer which I've done before. E.g.

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapGestureCaptured:)];
[self.scrollView addGestureRecognizer:tapRecognizer];

- (void)tapGestureCaptured:(UITapGestureRecognizer *)touch
{    
   CGPoint touchPoint=[touch locationInView:scrollView]; 
   // Perform action here. 
}

希望这对某人有帮助.再次感谢.

Hopefully this helps someone. Thanks again.

这篇关于UITableView-我可以跨多个行还是可以使用嵌套的UITableView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆