简体   繁体   English

拖出表格和响应者链

[英]Dragging Out of a Table and Responder Chain

I'm trying to build something where I can drag a person object from a UITableView into another UITableView. 我正在尝试构建一些东西,可以将一个人对象从一个UITableView拖到另一个UITableView中。 What I've got working so far is that when I select the item in the table to drag (UICustomTableViewCell), in the touchesMoved method, I pop the person object out of the cell and attach it to the superview. 到目前为止,我的工作是,当我在表格中选择要拖动的项目(UICustomTableViewCell)时,在touchesMoved方法中,将人员对象弹出单元格并将其附加到超级视图。 The problem that I seem to have is that as my finger keeps moving, the UITableView has captured the touch. 我似乎遇到的问题是,随着手指不断移动,UITableView捕获了触摸。 It seems to be the dominant object. 它似乎是主要对象。 The entire table scrolls as a consequence and my person object that I want to move stays in one place. 结果整个表格滚动,而我要移动的人员对象停留在一个位置。 If I pick up my finger and grab the person object again, everything moves fine. 如果我举起手指再次抓住人的物体,一切都会很好。 This isn't a very elegant implementation since I have two grabs instead of one nice smooth movement. 这不是一个非常优雅的实现,因为我有两次抓取而不是一次平稳的移动。

What I'm thinking the problem is, is that the UITableView is capturing the touch before the person object is and I somehow need to knock it out of the responder chain? 我在想的问题是,UITableView是否在人员对象之前捕获了触摸,而我却需要以某种方式将其从响应者链中剔除? I've tried setting the userInteractionEnabled to NO in the UICustomTableViewCell but no matter what, my person object is never the item that has the focus of the touch. 我试过在UICustomTableViewCell中将userInteractionEnabled设置为NO,但是无论如何,我的person对象永远不是具有触摸焦点的项目。 Is there a way to do this? 有没有办法做到这一点?

Any suggestions are greatly appreciated. 任何建议,不胜感激。 Thanks, mj 谢谢,mj

I figured out my own question. 我想出了自己的问题。 I needed overload the hittest method in the parent uiview. 我需要在父uiview中重载hittest方法。 This way I can guide which uiview receives touch focus. 这样,我可以指导哪个uiview获得触摸焦点。

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

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