-1
A
回答
0
在您的视图控制器
#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
相关问题
- 1. 重命名并移动多个图像
- 2. 在numpy中移动图像
- 3. 在CocoS2d中移动图像
- 4. 在Xcode中使用UITouches移动的图像
- 5. 平移多个图像simultaniosly
- 6. Xcode,iphone - 使图像动画在特定方向移动
- 7. Xcode中的滑动图像
- 8. 在图像视图中移动位图
- 9. Android - 移动单个图像
- 10. 在图像中移动像素统计
- 11. 如何在视图中移动图像
- 12. 在Android中滚动多个图像
- 13. 图像上的对象在图像移动时不会移动
- 14. Gimp:在一个图像中移动一个图层的位置
- 15. 移动图像在一个div HTML5 CSS3
- 16. 移动图像在同一轴线上的Xcode-IOS
- 17. 在Java中的多线程应用中移动图像/形状
- 18. 在div内移动图像?
- 19. 移动jQuery动画的多个实例的图像
- 20. 在android中移动图像部分在屏幕上移动
- 21. 如何将两个或多个图像浏览一起移动?
- 22. 在另一个透明图像上移动透明图像
- 23. 如何在移动视图中并排排列2个图像?
- 24. 移动图像imageview
- 25. 移动图像表
- 26. Matlab移动图像
- 27. JavaFx移动图像
- 28. jQuery移动图像
- 29. Flex移动图像
- 30. HTML |移动图像
很可能需要添加更多的细节来描述你”重新做你想做的事。 – ThomasW 2012-01-17 00:42:36