-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. Pygame中的多个图像的移动
- 2. 重命名并移动多个图像
- 3. 移动多个上传的图像
- 4. 在numpy中移动图像
- 5. 在CocoS2d中移动图像
- 6. 在pygame中移动图像
- 7. 在C#中移动图像
- 8. 在Android中移动图像
- 9. 在PictureBox中移动图像
- 10. 在pygame中移动图像?
- 11. 在Python中一次绘制并移动多个图像对象
- 12. xcode异步tableview加载图像移动listview图像去了
- 13. 平移多个图像simultaniosly
- 14. Xcode,iphone - 使图像动画在特定方向移动
- 15. Xcode中的滑动图像
- 16. 在图像视图中移动位图
- 17. 在网格中移动一个球xcode
- 18. 在图像中移动像素统计
- 19. Android - 移动单个图像
- 20. 在Android中动态地移动图像
- 21. 如何在视图中移动图像
- 22. 在wpf中滚动多个图像
- 23. 在iOS中拖动多个图像
- 24. 在Android中滚动多个图像
- 25. 获取2个图像在视图中拖动Xcode
- 26. 图像上的对象在图像移动时不会移动
- 27. Gimp:在一个图像中移动一个图层的位置
- 28. 移动图像在一个div HTML5 CSS3
- 29. 在图像元素内移动图像
- 30. 用Xcode 8中的按钮移动图像
很可能需要添加更多的细节来描述你”重新做你想做的事。 – ThomasW 2012-01-17 00:42:36