All I need it to move some view around based on pan gesture. The problem is that it doesn't happen instantly, just like Apple Maps, if I put down my finger on one point, and move it fast to any direction, the view will move with a delay, meaning I will be able to see the point that I put my finger on, and that is what I don't want.
Maybe it is impossible due to hardware limitations since in the simulator it works fine. Or maybe there is a better way that I don't know.
Thank you.
- (IBAction)pan:(UIPanGestureRecognizer *)sender
{
CGPoint center = [sender locationInView:sender.view];
self.myView.center = center;
}
When I first answered, I was presuming that there was something complicated about the view being dragged (e.g. a large
CALayer
shadow, which can be computationally expensive). Hence my original answer below. But in a subsequent exchange of comments, it has been discovered that one of the buttons had an pulsing animation, which is more likely to be the problem. The animation should be suspended during the dragging of the view if the dragging performance is not acceptable. Thus:Clearly, this can be combined with the rasterization of the image, discussed below, but I would try suspending the animation, like above, first.
Original answer:
If your view being dragged is at all complicated, you could try rasterizing it.
Add
QuartzCore.framework
to your target's "Link binary with libraries" settings.And then adjust the source to rasterize accordingly.
Such as:
As an aside, I'd suggest saving the
originalCenter
like this code does, so that if you grab the view being dragged a little off center, it won't jump jarringly on you.Try disabling animations when you set the new value for the center point.
If that helps you could try to smooth it with faster animation.
You could also try to disable the animations as described here: Explicitly disabling UIView animation in iOS4+
Shortly:
Once you manage to disable all animations during the repositioning, it's up to the speed of the hardware and your code.