В вашем контроллере вида
#import "ImageMove.h"
- (void)viewDidLoad
{
[super viewDidLoad];
ImageMove* imageMove = [[ImageMove alloc] initWithImage:[UIImage imageNamed:@"11.jpg"]];
[imageMove setFrame:CGRectMake(110, 60, [imageMove frame].size.width,[imageMove frame].size.height)];
[[self view] addSubview:imageMove];
[imageMove release];
ImageMove* imageMove1 = [[ImageMove alloc] initWithImage:[UIImage imageNamed:@"feder.jpg"]];
[imageMove1 setFrame:CGRectMake(110, 200, [imageMove1 frame].size.width,[imageMove1 frame].size.height)];
[[self view] addSubview:imageMove1];
[imageMove1 release];
}
это ваш класс imageView ...
@interface ImageMove : UIImageView {
}
@end
@implementation ImageMove
- (id) initWithImage:(UIImage *)image
{
if (self = [super initWithImage:image])
{
[self setUserInteractionEnabled:YES];
[self setMultipleTouchEnabled:YES];
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if ([touches count] == 1)
{
CGPoint newTouch = [[touches anyObject] locationInView:[self superview]];
CGPoint lastTouch = [[touches anyObject] previousLocationInView: [self superview]];
float xDif = newTouch.x - lastTouch.x;
float yDif = newTouch.y - lastTouch.y;
CGAffineTransform translate = CGAffineTransformMakeTranslation(xDif, yDif);
[self setTransform: CGAffineTransformConcat([self transform], translate)];
}
}
- (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesEnded:touches withEvent:event];
}
@end