简体   繁体   English

在iOS中嵌套的UITableview中滚动问题

[英]Scrolling issue in nested UITableview in iOS

I'm creating a layout where the data should scroll vertically and each rows data should scroll vertically. 我正在创建一个布局,其中数据应垂直滚动,每行数据应垂直滚动。 To accomplish this I have used UITableView as parent and inside each UITableViewCell , I am adding UITablview for vertical scroll. 为了实现这一点,我使用了UITableView作为父级,并且在每个UITableViewCell ,我正在为垂直滚动添加UITablview

The parent UITableView has only two section, each section has child UITableView . UITableView只有两个部分,每个部分都有子UITableView The Child tableView has more than 50 rows. Child tableView有超过50行。 I am facing scrolling issue. 我正面临滚动问题。 I want that the child UITableView scrolls only when the respective section reaches to top of the screen. 我希望子UITableView仅在相应部分到达屏幕顶部时滚动。 Now the behaviour is it scrolls independentaly. 现在的行为是它独立滚动。

How we can achieve this? 我们怎样才能做到这一点?

您必须创建内部UITableView的自定义子类,并根据您的条件覆盖以下方法并返回true / false:

touchesShouldBegin(_:with:in:)

Try by setting following property to the main table view. 尝试将以下属性设置为主表视图。

self.tableView!.delaysContentTouches = true
self.tableView!.canCancelContentTouches = true

Another option is, Use TableView inside CollectionView 另一个选项是,在CollectionView中使用TableView

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

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