简体   繁体   English

iOS-UITableView平移手势

[英]iOS - UITableView Pan Gestures

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. 首先,我在Interface Builder中创建了一个视图(我知道!),然后将xib文件加载到应用程序委托中的视图控制器中。 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. 该视图由3个表视图组成,其中两个具有相似的大小,而一个小视图位于一个角落。 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'? 如果用户仍然在单元格上有手套,他们可以将其拖到视图中,但是我如何才能使所有表视图位于同一“层”上? Ie 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! 谢谢!

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, 这不是最优雅的解决方案,您确实会失去联系,但确实可以,

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

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