How are objects made draggable on iphone?
How is an item/object moved by the user. e.g. apps can be moved on the homescreen and they icons follow the users finger.
How can e.g. a tableview cell contents be moved if the user holds down on it and then moves their finger?
What controls the movement of these objects to follow a users finger?
There is no built-in support of dragging controls and you need to implement one. My answer to another question is related and might help.
Dragging values onto labels
Related
I have a ScrollView with loads of buttons, My question is how to make the scrollview to remember the last scrolled position even after the scene is reloaded. In other words how to make the scroll view to remember the last viewed child so that if the scene is reloaded it should have that particular child in the center of the view. Please ask if you can't get the question
You want to save the normalized value, scrollView.horizontalScrollBar.value or scrollView.verticalScrollBar.value whichever applies, to .xml or just do a DontDestroyOnLoad(scrollView.gameObject)
If you use UICenterOnChild, simply store the currently centered object (using centeredObject) somehow (by index, by name, by whatnot), then do something like CenterOn(latestCenteredObject.transform) when loaded.
See UICenterOnChild docs for more.
I got an app that allows users to add content to a canvas. I would like to be able to offer the user an ability to move, rotate, resize, reflect this content. Currently I'm doing this with gestures, but would like to know if there is some sort of open-source widget that draws a box around the view and adds 4 buttons to do these functions:
rotate 90 degrees
rotate freely
resize
delete
Can anyone think of an open source framework that I can add to my project to create controls like the ones displayed?
I can probably build this by hand, but debugging gesture recognizers and view rotation is not the most fun thing, so I'm looking for something more polished.
Thank you!
Here's a link to an open source control on cocoa controls that looks like something you could use: TDResizerView.
"TDResizerView is used to resize and rotate an imageview with single finger"
Sounds like a good place to start from, even if you need to modify it.
I've never used this particular control though, so take my word for what it's worth.
edit: Also keep in mind that on iOS, users generally expect gestures. Forcing them to use the handles instead of pinching or rotating may be bad for your user experience, depending on why you want the handles instead.
Im making an iPad app that will have some objects on the screen in a menu area. I want the user to be able to touch down and drag from one of these objects to place a new copy of that object on the view.
To further explain, say I have a checkers chip on the side of the UIView in the "game piece" / menu area. I want the user to touch down and drag from that checkers piece to drag a new checker piece onto the game board. I dont want the original checker to move, its just a place holder, but I want to create a new object that is dragged from the first checker.
I see a couple of ways to do that however I cant figure out how to do it without the user picking up their finger to reselect the new game piece. I want the new piece to be drag able immediately after touching the first place holder object.
Any ideas? Please and thank you for the assistance.
I've solved this before by creating a copy of the UIView that I wish to move, then using the UIResponder API (touchesBegan, etc.) to move the new copy in its superview based on the drag gesture translation, thereby leaving the original "menu" view in situ. Does this make sense?
When you create the moveable copy, you can set its alpha or create a border or some other visual confection to indicate the provisional nature of the drag object.
I am wanting to create a button in my iPhone app that when touched will return other draggable elements to their original position. I have looked at the Apple "MoveMe' example, but that returns the button to the center of the screen. I want to be able to position draggable objects around the screen, drag the objects within the app, and then return them to their original starting positions by pressing a designated button.
Any help appreciated!
Cache the initial positions of your draggable objects, and use an event handler on the button to reset their positions. I'm a little confused. The MoveMe example code is exactly what you need to answer your question -- what more do you want? You won't find a perfect code example for any arbitrary problem you can dream up.
Play around with saving the original positions and using MoveMe to reset the objects and I bet you'll have what your looking for in no time at all.
I tried to find an easy solution for the following.
I have a main view which holds a tile. I want to drag and drop it over a UITableView. I could program the pick and drag already with UIGestureRecognizer.
Now my problem is how can I detect within the table view that there is an item going to be dragged above it. For instance I want to highlight the given row when the tile is moved above it.
I tried to add the touchesMoved/Began/Ended events to the viewCell. They does not get fires when I am dragging the tile over it (in other words the tile is hiding a portion of the viewCell under my finger). They get fired when there is no tile dragged above.
Is there an effective hittest method for that?
Thanks.
There are a whole bunch of UI issues here that should be addressed.
In general, Drag and drop on the iPhone is a BAD idea. It's very hard to do, and getting feedback is going to be problematic, because your finger will be obstructing the drag operation
using the table's selected cell to indicate 'dropability' may get you rejected by the app store reviewers; it's to indicate "I've selected this cell", not "I'll drop something onto it"
That said, you'll probably want to manage all your touch events in the 'source' view, and send the table messages from there, rather than trying to juggle messages around. Once your -touchesBegan:withEvent: has been called in one view, all subsequent -touchesMoved:withEvent: and -touchesEnded:withEvent: will be sent to that view for the life-cycle of that touch; forwarding them around will confuse the heck out of everyone involved.