How can I move around and slide away a UIView with touches and swipes?


How can I move around and slide away a UIView with touches and swipes?



I´m trying to animate a sort of draggable UIView where the behaviour should be something like this:

  • Drag along the screen following the touch of the user.
  • Detect a swipe touch and drag automatically with an initial speed and a negative acceleration that makes is stop after some time.

Something like moving around a photo and then through it to one side of the screen.

Any tips on this?


Anyone know how to slide in a UIDatePicker like keyboard?

1:

Managing data for UITableViews
A similar question was asked (by me) around 3 weeks ago. How to get a C method to accept UIImage parameter?Though any of the answers I received were a little off the mark the best advice was: 1- study Apple's MoveMe case for how to touch an object and drag it around. how to release uiview added as subview in scrollview?And 2- you "throw" the object by basically comparing the [touch locationInView:self.view] to the [touch previousLocationInView:self.view] in touchesEnded (could also store a reference to first touch in touchesBegan although I find this less helpful as user may pause) using the time stamp of each you must determine the direction of swipe (flick) and rate of speed and use them to send your little UIView flying around. Populate a UITableView with dataObviously you want to apply forces ("friction") or whatever to slow it down so it doesn't fly right of your screen.... Dynamically change url or WordPress theme if UserAgent is iPhone
inheritance in objective CProgram to change the phone numbers a call is redirected to if a mobile phone cannot be reached?

2:

I am not sure. But may be you must use decelerating property of UIScrollView object. Put your imageView in UIScrollView and use this property. Its a BOOL var and the returned value is YES if user isn't dragging the content although scrolling is still occurring..

3:

Take a look at the MoveMe sample project from Apple (registration may be required). It demonstrates how to have a placard follow a touch as well as transform itself based on different touches.. Essentially, the idea is this you override the UIResponder touch methods to analyze what kind of touch the device received, and then either move the object to follow the user's finger or commit it a speed in a direction depending on whether it was a slow drag or a swipe. You must then use Core Animation to animate changes to the object's frame..


80 out of 100 based on 35 user ratings 190 reviews