简体   繁体   English

iOS拖放

[英]iOS Drag and drop

I would like to make an easy app - game with a letters. 我想做一个简单的应用程序 - 用字母游戏。

I am searching for an example, how to drag an image and drop it to a position which belongs only to this image. 我正在寻找一个例子,如何拖动图像并将其放到仅属于该图像的位置。

There will be for example a picture of apple on background and 5 UIImageView with letters A, P, P, L, E. You take a letter A and bring it to the right UIImageView (which belongs only to the letter A - in another you can´t). 例如,背景上有一个苹果的图片,有一个字母A,P,P,L,E的UIImageView。你拿一个字母A并把它带到右边的UIImageView(它只属于字母A - 在另一个你不容)。 Than letter L and so on ... until there is written apple. 比字母L等...直到有写苹果。

I can drag and drop each letter everywhere on a screen (there exists a lot of tutorials :)). 我可以在屏幕上随处拖放每个字母(存在很多教程:))。

But I don´t know, how to drop for example letter A - to the right UIImageView who was made only for a letter A. 但我不知道,如何删除例如字母A - 右边的UIImageView,只为字母A而制作。

Do you know about some tutorial or source code or example? 你知道一些教程或源代码或例子吗?

Thank you very much... 非常感谢你...

There's a simple open-source framework for iOS called "iOS-DragAndDrop" that does exactly what you need. 有一个简单的iOS开源框架叫做“iOS-DragAndDrop”,可以完全满足您的需求。 You can define any UIView as a draggable view, and you can define specific views (including invisible ones) that that draggable view can be dropped into. 您可以将任何UIView定义为可拖动视图,并且可以定义可拖放视图的特定视图(包括不可见视图)。

Check it out: iOS-DragAndDrop on Github 看看: Github上的iOS-DragAndDrop

There's documentation at that link as well. 该链接也有文档。

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

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