当前位置:  开发笔记 > 编程语言 > 正文

警告:函数“ min”的隐式声明在C99中无效

如何解决《警告:函数“min”的隐式声明在C99中无效》经验,为你挑选了1个好方法。

所以我买了这个应用程序,而开发人员也无法就此问题进行联系,所以我希望可以在这里得到一些帮助。

当我在Xcode中构建应用程序时,出现错误消息:

GGDraggableView.m: Implicit declaration of function 'min' is invalid in C99  

我还不太擅长Obj-c或Swift,所以我仍然在学习。
我试图在Google和此处查找错误,但无法真正获得任何答案。

怎么了?
这是整个课程和错误的图片:

#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

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

提前致谢



1> max_..:

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

您的电话应该是:

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

推荐阅读
小色米虫_524
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有