2013-03-06 61 views

回答

1

我想在选择器中,通过平移手势调用的设置视图的中心或原点相应的平移点。

这是你的代码应该是什么样子,以解决您的问题:

- (void)thePanSelector:(id)sender{ 
    UIPanGestureRecognizer *recognizer = (UIPanGestureRecognizer *)sender; 
    CGPoint p = [recognizer locationInView:theSuperView]; 
    float boundedX = MAX(0,MIN(theSuperView.frame.size.width,p.x)); 
    float boundedY = MAX(0,MIN(theSuperView.frame.size.height,p.y)); 
    CGPoint boundedPoint = CGPointMake(boundedX,boundedY); 
    view.center = p; 
} 

这个代码是未经测试,所以你可能需要用一下boundedX的价值观和boundedY

+0

@ajeet做你试试这个吗?你是如何解决你的问题的? – 2013-03-06 14:30:34

相关问题