PanGesture with multiple subviews

The following code snippet is based on the iPhone documentation for handling the pan gesture, although theres still used the translate method which has been replaced. The method also caters for panning all of the views subviews so that everything moves.

- (IBAction)handlePanGesture:(UIPanGestureRecognizer *)sender {
	static CGPoint prevTranslate;

    CGPoint translate = [sender translationInView:self.OfficeImage];
		UIView *subView;
	for(subView in self.view.subviews)
	{

		CGRect newFrame = subView.frame;
		newFrame.origin.x += (translate.x - prevTranslate.x);
		newFrame.origin.y += (translate.y - prevTranslate.y);
		subView.frame = newFrame;
	}

	prevTranslate = translate;

    if (sender.state == UIGestureRecognizerStateEnded)
        prevTranslate = CGPointMake(0, 0);
}


Great tool for iPhone Mockups

Used OmniGraffle to produce mockups for my latest iPhone project, its pretty easy yo use and there are a number of good stencils that allow for most of the UI Kit controls and even the iPad!