所以我买了这个应用程序,开发人员无法联系到这个问题,所以我希望我能在这里得到一些帮助。
当我在Xcode中构建应用程序时,我收到错误消息:
GGDraggableView.m: Implicit declaration of function 'min' is invalid in C99
我对Obj-c或Swift并不擅长,所以我还在学习 我试图在谷歌和这里看错误,但不能真正得到任何工作的答案。
#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
我希望你们能在这里帮助我走正确的道路,或者神奇地带来修复。
提前致谢
答案 0 :(得分:4)
编译器告诉您min(a)
函数尚未定义。正如之前的开发人员在代码中的其他位置使用的那样,您正在寻找的宏是完全大写的MIN(a, b)
并且需要两个参数,返回最小的。
您的电话应该是:
CGFloat overlayStrength = MIN(fabdistance / 100, 0.4);