Вопрос

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