Swift:向下滚动时下拉溢出消失 [英] Swift: dropdown overflow disappears when scrolling down
问题描述
我正在这个项目上工作,在这里我使用tableView单元格中的下拉菜单.我正在使用以下代码使下拉部分溢出tableView单元格底部
cell.clipsToBounds=false
cell.contentView.clipsToBounds=false
一切正常,但是当我向下滚动tableView直到下拉部分不再可见时,溢出停止工作.您可以在下面的项目中看到问题的所在
https://github.com/Rawchris/Drop-down-overflow2
在项目中,我在每个单元格中都放置了下拉按钮,但是如果它只是第一个正在工作的单元格,那就很好.希望您能提供帮助.请告诉我是否需要更多信息.
问题不是溢出停止工作" ...问题是表视图单元格未按顺序绘制.
从其他问题中获取答案: https://stackoverflow.com/a/61252794/6257435 >
我缩短了单元格的高度,以便于查看.
在此图像中:
在点击第8行"按钮之前,我上下滚动了几次.如您所见,灰色的下拉"菜单隐藏在第9行和第10行的后面.
使用Debug View Hierarchy
,您可以确切地看到正在发生的事情:
您可以通过使用闭包或委托协议告诉您的tableViewController在打开菜单时将该单元格置于最前面来解决此问题,但是...当您打开菜单时,仍然可能遇到问题在显示下拉"时滚动.同时显示多个行的下拉列表"时,您还会遇到问题.
通常,超出其他视图范围不是一个好主意.可能会出现许多问题.另外-当然,这可能仅是个人意见-整个下拉选择列表"在手机或平板电脑上感觉非常不合适.它带来了笨拙/笨拙的用户体验.如果我是你,我会重新考虑自己的方法.
I am working on this project where I am using drop down menus in tableView cells. I am using the following code to make the drop down part overflow the tableView cells bottoms
cell.clipsToBounds=false
cell.contentView.clipsToBounds=false
Everything works fine, but when I scroll down the tableView till the drop down part is not visible anymore, the overflow stops working. You can see the problem in action in the project below
https://github.com/Rawchris/Drop-down-overflow2
In the project I have put drop down buttons in every cell, but it is fine if it is just the first one that is working. I hope you are able to help. Please tell me if you need anymore information.
The problem is not that "overflow stops working" ... the problem is that table view cells are not drawn in order.
Taking the answer from your other question: https://stackoverflow.com/a/61252794/6257435
I shortened the cell heights to make it easier to see.
In this image:
I scrolled up and down a few times before tapping the "Row 8" button. As you can see, your gray "drop down" menu is hidden behind rows 9 and 10.
Using Debug View Hierarchy
you can see exactly what's going on:
You could get around this by using a closure or delegate protocol to tell your tableViewController to bring that cell to the front when the menu is opened, but... you may still run into issues when scrolling while a "drop down" is showing. You'll also hit problems when the "drop down" is showing for multiple rows at the same time.
In general, it's not a good idea to draw outside the bounds of other views. Many issues can arise. Also - of course, this may be considered just personal opinion - the whole "drop down selection list" feels very out-of-place on a phone or tablet. It makes for a rather clunky / awkward user experience. If I were you, I'd re-think my approach.
这篇关于Swift:向下滚动时下拉溢出消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!