【发布时间】:2013-12-14 03:25:53
【问题描述】:
如何在视图控制器周围移动多个 UIImage 视图?
我已经设法使用了这段代码;
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
printf("touch began --------- |n");
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
printf("touch moved --------- |n");
UITouch *myTouch = [touches anyObject];
startPoint = [myTouch locationInView:self.view];
ball.center = CGPointMake(startPoint.x, startPoint.y);
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
printf("touch end --------- |n");
}
上面的代码使我可以通过触摸移动一个 UIImage 视图,但是,我希望能够移动 100 个左右。当前,此代码还可以在您在屏幕区域周围移动手指时,图像会跳到您的手指。
这是最好的方法吗?还是平移手势更好?
请帮我完成,以便我可以通过触摸在我的视图控制器周围移动多个图像,如果您使用上面的代码,请阻止图像跳跃!
请帮忙!
.H 文件用于回答推荐;
@interface CMViewController : UIViewController {
CGPoint startPoint;
}
@property CGPoint startPoint;
@property (strong, nonatomic) IBOutlet UIImageView *smyImageView;
@property (strong, nonatomic) IBOutlet UIImageView *smyImageView1;
@end
谢谢
【问题讨论】:
标签: uiimageview touch move uipangesturerecognizer