UITableView:将一行拖到另一个上 [英] UITableView: Drag a row onto another one

查看:152
本文介绍了UITableView:将一行拖到另一个上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UITableView表示一个对象列表,我希望用户触摸一个对象,将其拖动到另一个对象上(以组合它们),并看到两个消失,并出现一个新的对象。我想我不能用标准的表视图编辑方法(一行不能拖到另一个,我是对的)。我会写我的触摸听众吗?我如何做到这一点?

解决方案

我设法找到一个解决方法:在首次点击自定义UITableCellView后,我创建一个新的UIView放在屏幕的另一个触摸+拖动的窗口顶部。



另一个触摸创建一个UIImageView,将不起眼的点击单元格复制为图像。这个UIImageView可以沿着UIView拖动,然后在必要的时候被关闭。



当我结束触摸时,如果它结束了另一个单元格,我会得到它的indexPath并计算一致的动作


I have a UITableView that represents a list of objects, I'd like the user to touch an object, drag it onto another one (as to combine them) and seeing the two disappearing and a new one appearing. I guess that I can't do this with the standard table view editing methods (a row cannot be dragged onto another one, am I right?). Shall I write my touch listeners? how can I do that?

解决方案

I managed to find a workaround: after the first click on a custom UITableCellView I create a new UIView to put on top of the window that intercepts another touch+drag.

The other touch creates a UIImageView that copies the undelying clicked cell as a Image. This UIImageView can be dragged around along the UIView and then dismissed when necessary.

When I end the touch I look if it ended up a another cell, if so I get its indexPath and compute a coherent action

这篇关于UITableView:将一行拖到另一个上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆