2011-12-08 92 views
0

我想贏得我的框架移動40/3px然後停止移動! 如何停止移動並將框架x更改爲40 + 320!謝謝如何停止touchesMoved

-(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

更改你的代碼是這樣的:

-(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]; 
    } 
} 

希望它可以幫助