iOS - UITableView 平移手势
这可能会成为两个问题,但我相信解决第一个问题将在很大程度上解决第二个问题。
首先,我在 Interface Builder 中创建了一个视图(我知道!),然后将 xib 文件加载到应用程序委托中的视图控制器中。所有这一切都按预期顺利进行。 该视图由 3 个表格视图组成,其中两个大小相似,一个较小的位于角落。 将单元格添加到一个表视图中,添加平移手势以允许在场景中移动。
但是,如果单元格从其表格视图中移动,它似乎会移到父视图后面,如下面的屏幕截图所示:
两个表之间的灰线是父视图的灰色背景。如果用户仍然将他/她的手套放在单元格上,他们可以将其拖动到视图中,但我怎样才能使所有表格视图都位于同一“层”上? 即,将单元格从一个表视图拖动到另一个表视图,并显示单元格悬停在两个视图上。
这引出了我的第二个问题,我还不会问这个问题,因为我相信这个问题的解决方案将解决我当前的问题。但我会进一步解释。 在我的平移手势中,我使用检查内的点来查看单元格是否在表格视图内,当前从任何表格中平移单元格都会使其打印。几乎就像视图占据了整个屏幕,即使它们的大小不合适?
欢迎所有想法!谢谢!
This may turn out to be 2 questions in one, but I believe solving the first will go most of the way to solving the second.
First, I have created a view in Interface Builder (I know!) and I load the xib file into my view controller in the app delegate. All of this runs smoothly and as expected.
The view consists of 3 table views, two of a similar size and one small one in a corner.
A cell is added to one table view a pan gesture is added to allow movement around the scene.
However, if a cell is moved from it's table view, it appears to go BEHIND the parent view, as per the screenshot below:
The grey line between the two tables is the gray background of the parent view. If the user still has his/her mitts on the cell, they can drag it into view but how can I make it so that all table views are on the same 'layer'?
I.e. so that dragging a cell from one table view to another with show the cell hovering over both views.
This leads me onto my second question, which I will not ask yet as I believe the solution to this will solve my current issue. but I will explain for further clarity.
In my pan gesture, I use a point inside check to see if the cell is within a table view, currently panning a cell from any table makes it print. It is almost like the views take up the whole screen, even though they are sized not to?
All ideas welcome! Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是通过侦听离开表视图边界的单元格来解决的,当发生这种情况时,我将单元格转移到它已拖动到的表视图上,并将其添加到列表的底部。
这不是最优雅的解决方案,你确实失去了联系,但它确实有效,
This was solved by listening for the cell leaving the bounds of the table view, when this happened, I transferred the cell across the table view that it has been dragged to, adding it to the bottom of the list.
Not the most elegant solution and you do lose the touch but it does work,