0

我正在尝试编写一个应用程序来允许一个人在地球图像周围拖动。

touchesmoved当用户开始拖动他的脚时调用该方法,但从[[ event allTouches] anyObject]不返回earth对象,因此它永远不会被拖动,

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

    UITouch *touch=[[ event allTouches] anyObject];

    if ( [touch view] == earth )
    {
        CGPoint location = [ touch locationInView: self.view];
        earth.center=location;          
    }
}
4

1 回答 1

0

用于触摸使用UITouch *touch=[touches anyObject];

改变你的touchesMoved:喜欢:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
 {

    UITouch *touch=[ touches anyObject];

    if ( [touch view] == earth )
    {
        CGPoint location = [ touch locationInView: self.view];
        earth.center=location;          
    }
}
于 2012-10-31T18:32:58.627 回答