简体   繁体   中英

Drag and drop over 2 different views

I have this following problem which I can't seem solve:

In my top view (a menu bar), I have a UIButton on which I want the user to press and then drag and drop an object (OpenGL object that spawns fine) to the view under the menu bar (an EAGLView ). My problem is that I cannot pass the touch location of where the user presses down on the button to the EAGLView .

I have tried several solutions :

  1. Assign a selector to the Drag-In-Touch function of the UIButton . This allows me to get the touch position I could want, but this location only stays in bounds of the view holding the UIButton (the menu bar)

  2. Override the touchesBegan / Moved / Ended of the UIButton so they use the touches of the nextResponder.nextResponder (making this the EAGLView ). This seemed to work for the touchesBegan , but the second I try to move around, touchesMoved is called once and then stops.

If any of you could point me to any possible ways of accomplishing what I want, I'd be most grateful.

Not completely answering the question here, but what you want could be solved by adding UIviews instead of UIButtons and dragging them on screen using a Pangesture recognizer. Then, you simply load or place the object you want under this view at the moment the user ends the pan/drag motion.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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