Comments (5)
Ok, I forgot to add the DraggableLocations to the view. But the DraggableObjects still start at the top of the screen.
from ios-draganddrop.
Yes, the code should be working alright... I'm using it in several production applications, so if you're sure there's a bug, I'd be very interested in hearing more about it!
Looking at your code, I had one quick thought... try placing the [self.view addSubview:draggable]
line before the [home addDraggableObject:draggable animated:YES]
line. I think the way the placement of the SEDraggable
inside the SEDraggableLocation
is calculated, the SEDraggable
must be a child of a view before it can be added to an SEDraggableLocation
. I could be wrong, though, so I'll keep my eye on this issue.
from ios-draganddrop.
Thanks for the reply. I ended up using a different approach though, so I cant tell you if your proposed solution worked.
from ios-draganddrop.
Have the same issue. Your solution haven't helped.
from ios-draganddrop.
Oh, I see what's wrong here -- you're adding the SEDraggable
object directly to the view after you've already added it to its home location. So it's getting removed from its home location and then added to self.view
. That's why it's appearing at the top of the screen.
SEDraggable
and SEDraggableLocation
are both subclasses of UIView
, so when you call the -addDraggableObject:
method to add the draggable to the home location, it automatically its -addSubview:
method, inherited from UIView
. And of course, -addSubview:
automatically calls removeFromSuperview
.
First thing I'd suggest in general is to check out the example project, which I've added to the repo pretty recently.
But as far as the code sample you posted above, just try the following:
- Remove the line that adds the draggable object to
self.view
(the line is[self.view addSubview:draggable];
) and replace it with a line that adds the home location toself.view
instead (since the draggable object is already inside the location). Something like this should work:[self.view addSubview:home];
- In general you probably shouldn't specify
animated:YES
when you're adding objects to locations in your init method (i.e., before the views are all visible). It might work, but I wouldn't be surprised if there were some bugs with the calculations that determine the positioning and layout of the objects. YMMV.
from ios-draganddrop.
Related Issues (2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ios-draganddrop.