ios - 警告: Implicit declaration of function 'min' is invalid in C99

标签 ios objective-c error-handling

所以我买了这个应用程序,而开发人员也无法就此问题进行联系,所以我希望可以在这里得到一些帮助。
当我在Xcode中构建应用程序时,出现错误消息:

GGDraggableView.m: Implicit declaration of function 'min' is invalid in C99  
我还不太擅长Obj-c或Swift,所以我仍然在学习。
我试图在Google和此处查找错误,但无法真正获得任何答案。
怎么了?
这是整个类(class)和错误的图片:
enter image description here
#import "GGDraggableView.h"
#import "GGOverlayView.h"

@interface GGDraggableView ()
@property(nonatomic, strong) UIPanGestureRecognizer *panGestureRecognizer;
@property(nonatomic) CGPoint originalPoint;
@property(nonatomic, strong) GGOverlayView *overlayView;
@end

@implementation GGDraggableView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (!self) return nil;

    
    self.overlayView = [[GGOverlayView alloc] initWithFrame:self.bounds];
    self.overlayView.alpha = 0;
    [self addSubview:self.overlayView];

    return self;
}

-(void)awakeFromNib
{

    self.panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(dragged:)];
    [self addGestureRecognizer:self.panGestureRecognizer];
    self.backgroundColor = [UIColor whiteColor];

}

- (void)loadImageAndStyle
{
    UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bar"]];
    [self addSubview:imageView];
    self.layer.cornerRadius = 8;
    self.layer.shadowOffset = CGSizeMake(7, 7);
    self.layer.shadowRadius = 5;
    self.layer.shadowOpacity = 0.5;
}

- (void)dragged:(UIPanGestureRecognizer *)gestureRecognizer
{
    CGFloat xDistance = [gestureRecognizer translationInView:self].x;
    CGFloat yDistance = [gestureRecognizer translationInView:self].y;

    switch (gestureRecognizer.state) {
        case UIGestureRecognizerStateBegan:{
            self.originalPoint = self.center;
            break;
        };
        case UIGestureRecognizerStateChanged:{
            CGFloat rotationStrength = MIN(xDistance / 320, 1);
            CGFloat rotationAngel = (CGFloat) (2*M_PI/16 * rotationStrength);
            CGFloat scaleStrength = 1 - fabs(rotationStrength) / 4;
            CGFloat scale = MAX(scaleStrength, 0.93);
            CGAffineTransform transform = CGAffineTransformMakeRotation(rotationAngel);
            CGAffineTransform scaleTransform = CGAffineTransformScale(transform, scale, scale);
            self.transform = scaleTransform;
            self.center = CGPointMake(self.originalPoint.x + xDistance, self.originalPoint.y + yDistance);

            [self updateOverlay:xDistance];

            break;
        };
        case UIGestureRecognizerStateEnded: {
            [self resetViewPositionAndTransformations];
            break;
        };
        case UIGestureRecognizerStatePossible:break;
        case UIGestureRecognizerStateCancelled:break;
        case UIGestureRecognizerStateFailed:break;
    }
}

- (void)updateOverlay:(CGFloat)distance
{
    if (distance > 0) {
        self.overlayView.mode = GGOverlayViewModeRight;
    } else if (distance <= 0) {
        self.overlayView.mode = GGOverlayViewModeLeft;
    }
    CGFloat overlayStrength = min(fabdistance) / 100; 0.4;
    self.overlayView.alpha = overlayStrength;
}

- (void)resetViewPositionAndTransformations
{
    if (self.center.x < 50)
    {
        [UIView animateWithDuration:0.4
                         animations:^{
                             self.center = CGPointMake(-self.frame.size.width/2, self.frame.size.height/2);
                             self.transform = CGAffineTransformMakeRotation(0);
                             self.overlayView.alpha = 0;
                         } completion:^(BOOL finished){
                         
                             if (finished)
                                 self.center = self.originalPoint;
                                 }];
            }
    else if (self.center.x > 270)
    {
       [UIView animateWithDuration:0.4
                             animations:^{
                                 self.center = CGPointMake(self.frame.size.width *2, self.frame.size.height/2);
                                 self.transform = CGAffineTransformMakeRotation(0);
                                 self.overlayView.alpha = 0;
                             } completion:^(BOOL finished){
                                 
                                 if (finished)
                                    self.center = self.originalPoint;
                             }];

        
    }
    else
    {
        [UIView animateWithDuration:0.2
                         animations:^{
                             self.center = self.originalPoint;
                             self.transform = CGAffineTransformMakeRotation(0);
                             self.overlayView.alpha = 0;
                         }];
    
    }
}

- (void)dealloc
{
    [self removeGestureRecognizer:self.panGestureRecognizer];
}

@end
我希望你们能在这里帮助我走上正确的道路,或者神奇地提供解决方案。
提前致谢

最佳答案

编译器告诉您尚未定义min(a)函数。正如先前的开发人员在代码中的其他地方使用的那样,您要查找的宏完全是大写的MIN(a, b)并接受两个参数,返回最小的参数。

您的电话应该是:

CGFloat overlayStrength = MIN(fabdistance / 100, 0.4);

关于ios - 警告: Implicit declaration of function 'min' is invalid in C99,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34617005/

相关文章:

iphone - 将本地 css 注入(inject) UIWebView

ios - 无法在 NSHomeDirectory 下创建目录

ios - 如何配置用于身份验证的 HTTP header ?

testing - 随机场景端到端测试

php - 出现 MySQL 错误 "unknown column"但该列存在

iOS 存储 CLLocation 核心数据作为可转换的 NSKeyedUnarchiveFromDataTransformerName 错误 CoreData : warning: no NSValueTransformer

ios - iOS 中的 VOIP 拨号器

iphone - 两次之间的 Objective-C 中点

ios - 在 uitableviewcell 上更快地加载图像,从互联网下载

php - 错误PHP 7.4尝试访问类型为bool的值中的数组偏移量