In this application we will see to the image as moved, with touch function we where everyone on the screen moves.
Step 1: Create a view-based application with template. Enter the name of “Rotateimage”.
Step 2: Xcode automatically creates the directory structure and essential framework adds. You can explore the directory structure to verify the contents of the directory.
Step 3: Xpand created classes and Interface Builder notice the RotateImageViewController class for you. Expand resources and note that the template generates a separate nib, RotateImageViewController.xib for the “RotateImage”.
Step 4: We must add UIView class in your project. SELECT classes-> add new file-> cocoa touch class-> objective C class-> select UIView from the subclass of->. Type the file name “Imageview”.
Step 5: We have added a resource in the resources folder. Enter the name of the resource “1.png”.
Step 6: Specified in the ImageView.h file of the parent class as a UIImageView. So you take the following changes to the file:
# Import Step 7: Open the file ImageView.m, make the following modifications to the file. -(Id) image InitWithImage:(UIImage_*) {} -(void) TouchesMoved:(NSSet_*) WithEvent:(UIEvent_*) event touches Step 8: Where the RotateImageViewController.h file, we have “ImageView.h” file import. Step 9: Open the RotateImageViewController.m file, we create a ImageView and make them visible. So you take the following changes to the file. Games (void) {} Step 10: Now compile and run the application in the Simulator. You can Download source code from here RotateImage
@ Interface ImageView: UIImageView {}
}
If (self = [super InitWithImage: image]) {}
[Self SetUserInteractionEnabled: YES];
[Self SetMultipleTouchEnabled: YES];
} return self;
}
{
If ([count touched] == 1) {}
CGPoint NewTouch = [[touches AnyObject] LocationInView: [self Superview]];
CGPoint load touch = [[touches AnyObject] PreviousLocationInView: [self Superview]];
float xDif = newTouch.x – lastTouch.x;
float yDif = newTouch.y – lastTouch.y;
Translate CGAffineTransform = CGAffineTransformMakeTranslation (xDif, yDif);
[Self set transform: CGAffineTransformConcat (translate [self transformation])];
}
}
[super games];
ImageView * ImageView = [[ImageView alloc] InitWithImage: [UIImage imageNamed:@"1.png]” “];
[ImageView set frame: CGRectMake(110,_180,_[imageView_frame].size.width,[imageView_frame].size.height)];
[[Self view] AddSubview: imageView];
[ImageView release];
}