OGeek|极客世界-中国程序员成长平台

标题: ios - 需要在icarousel中拖放 View [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-13 12:37
标题: ios - 需要在icarousel中拖放 View

我在我的 iPad 应用程序中使用 icarousel。我想要一个功能,比如在 icarousel 中拖放对象。将 View 拖出轮播以从中删除项目,然后将 View 拖放到轮播中以将项目添加到其中。我已从 https://github.com/nicklockwood/iCarousel 下载了 icarousel

我已经尝试了使用委托(delegate)方法的拖放功能

-(void)touchesBeganNSSet *)touches withEventUIEvent *)event
-(void)touchesMovedNSSet *)touches withEventUIEvent *)event
-(void)touchesEndedNSSet *)touches withEventUIEvent *)event

但是整个 View 都搞砸了。请帮帮我。 提前谢谢你。



Best Answer-推荐答案


这是一篇旧帖子,但以防万一您仍然被卡住,这就是我们所做的。

拉出 View :

  1. 向 iCarousel 添加平移手势识别器
  2. 在识别器StateBegan 上标记触摸点
  3. 在recognizerStateChanged 上调整 View 的框架或变换
  4. 检查recognizerStateEnded上的位置

    4.1 如果没有完全用完,则退货

    4.2 如果完全退出,则从数据源中删除项目

  5. 重新加载 iCarousel

您可以执行与您放置在 iCarousel 上的 View 非常相似但相反的操作。

关于ios - 需要在icarousel中拖放 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9883596/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://sqlite.in/) Powered by Discuz! X3.4