UIViewController将float值传递给UIView方法

时间:2013-05-21 15:31:43

标签: ios ipad uiview uiviewcontroller

我有一个带HandlePan方法的ViewController:

-(void)handlePan:(UIPanGestureRecognizer *)gestureRecognizer
{
    UIView *piece = [gestureRecognizer view];

    [self adjustAnchorPointForGestureRecognizer:gestureRecognizer];

    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
        CGPoint translation = [gestureRecognizer translationInView:[piece superview]];
        CGFloat panSpeed = (translation.x+translation.y)/2;
        NSLog(@"PanSpeed %f",panSpeed);
        [someview viewPan:panSpeed];
    }

}

然后我有UIView名为someview的方法:

- (void) viewPan:(float *)PanAngle {
    NSLog(@"Panning...%@",PanAngle);
}

但我为nil获得PanAngle

这样做的正确方法是什么?谢谢!

1 个答案:

答案 0 :(得分:2)

float不是对象,因此不需要指针

- (void)viewPan:(float)PanAngle{
    NSLog(@"Panning...%f",PanAngle);
}