문제

In my interface there are two CFFloat properties. I am attempting to use them in a gesture recognizer but I continue to get the errors "invalid operands to binary expression float and double.." in the if statement with the "allTouchesAreOnPreviewLayer". I'm unsure of how to properly fix this. Let me know if you need more information. I'm attempting to implement a pinch to zoom on a UIView.

Interface properties:

CGFloat *startingScale;
CGFloat *effectiveScale;

Implementation methods:

-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
 {
 if ([gestureRecognizer isKindOfClass:[UIPinchGestureRecognizer class]]) {

    startingScale = effectiveScale;
}

return YES;
}

-(IBAction)handlePinchGesture:(UIPinchGestureRecognizer *)recognizer
{
NSLog(@"Pinched View");


BOOL allTouchesAreOnThePreviewLayer = YES;
NSUInteger numTouches = [recognizer numberOfTouches], i;
for ( i = 0; i < numTouches; ++i ) {
    CGPoint location = [recognizer locationOfTouch:i inView:imagePreview];
    CGPoint convertedLocation = [captureVideoPreviewLayer convertPoint:location fromLayer:captureVideoPreviewLayer.superlayer];
    if ( ! [captureVideoPreviewLayer containsPoint:convertedLocation] ) {
        allTouchesAreOnThePreviewLayer = NO;
        break;
    }
}

//ERRORS ARE HERE:

if ( allTouchesAreOnThePreviewLayer )
{
    effectiveScale = startingScale * recognizer.scale;
    if (effectiveScale < 1.0)
        effectiveScale = 1.0;
    CGFloat maxScaleAndCropFactor = [[stillImageOutput connectionWithMediaType:AVMediaTypeVideo] videoMaxScaleAndCropFactor];
    if (effectiveScale > maxScaleAndCropFactor)
        effectiveScale = maxScaleAndCropFactor;
    [CATransaction begin];
    [CATransaction setAnimationDuration:.025];
    [captureVideoPreviewLayer setAffineTransform:CGAffineTransformMakeScale(*(effectiveScale), *(effectiveScale))];
    [CATransaction commit];
}



}
도움이 되었습니까?

해결책

CFGloat is a primitive type, not a class. Get rid of the asterisks in the declarations. You want:

CGFloat startingScale;
CGFloat effectiveScale;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top