如何停止touchesMoved

时间:2011-12-08 09:05:01

标签: iphone ios cocoa-touch

我想赢得我的框架移动40 / 3px然后停止移动! 如何停止移动并将第x帧更改为40 + 320!谢谢

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if(self.frame.origin.x > 40/3) {
            CGRect myFrame = self.frame; 
            myFrame.origin.x = 40 + self.frame.size.width;
            self.frame = myFrame;
    }
}

1 个答案:

答案 0 :(得分:-1)

更改您的代码:

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
    if(self.frame.origin.x > 40/3) {
            CGRect myFrame = self.frame; 
            myFrame.origin.x = 40 + self.frame.size.width;
            self.frame = myFrame;
            [self touchesEnded:touches withEvent:event];
    }
}

希望有所帮助