Ios 在iphone sdk中移动屏幕中的对象

Ios 在iphone sdk中移动屏幕中的对象,ios,ios6,ios7,core-motion,sphero-api,Ios,Ios6,Ios7,Core Motion,Sphero Api,我知道使用sphero ios sdk。我想知道,当我使用Sphereo将设备从一个方向移动到另一个方向时,如何在设备屏幕上实现对象从一个点到另一个点的移动。我曾主持过Sphereo的“流线型动画”演示项目。我还参考了sphero ios sdk的其他示例项目,但我无法理解,当我将设备从一个方向移动到另一个方向时,如何实现对象的移动。你的答复会很好。试试这个 我正在拍摄移动的图像 UIImageView*动画图像 UIPangEstureRecognitzer*PanRecognitzer=[[

我知道使用sphero ios sdk。我想知道,当我使用Sphereo将设备从一个方向移动到另一个方向时,如何在设备屏幕上实现对象从一个点到另一个点的移动。我曾主持过Sphereo的“流线型动画”演示项目。我还参考了sphero ios sdk的其他示例项目,但我无法理解,当我将设备从一个方向移动到另一个方向时,如何实现对象的移动。你的答复会很好。

试试这个

我正在拍摄移动的图像

UIImageView*动画图像

UIPangEstureRecognitzer*PanRecognitzer=[[UIPangEstureRecognitzer alloc]initWithTarget:self action:@selector(panDetected:)]

panRecognizer.delegate=self

[animationImage AddgestureRecognitor:装甲识别器]

在方法中,您应该这样实现

-(void)panDetected:(UIPanGestureRecognizer *)panRecognizer
{

   CGPoint translation = [panRecognizer translationInView:self.view];

   CGPoint imageViewPosition = animationImage.center;
   imageViewPosition.x += translation.x;

   imageViewPosition.y += translation.y;
    
   animationImage.center = imageViewPosition;

   [panRecognizer setTranslation:CGPointZero inView:self.view];
        
}