听起来您应该使用 UIPanGestureRecognizer 来执行此操作。基本上,这将跟踪您的手指按压,只要您的手指被按压,它就会在特定视图中进行翻译。
编码的简要想法类似于:
UIPanGestureRecognizer *touch = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(someFunction:);
[self.view addGestureRecognizer:touch];
[touch release];
这会将手势识别器添加到您的视图中(假设此代码在视图控制器中)。然后你需要在函数“someFunction”中添加“地球旋转”代码。
像这样的东西:
-(void) someFunction:(UIPanGestureRecognizer *)recognizer {
CGPoint translation = [recognizer translationInView:self.view];
// Your globe rotation code goes here
}
[recognizer translationInView:self.view] 将为您提供手势识别器的翻译。您可以使用它来设置地球的图像或变换,但是您正在处理实际的旋转。
希望这可以帮助。
干杯。