我收到了Xcode中的警告:
格式指定'int‘类型,但参数具有'UIViewContentMode’类型
我有一个用于调整UIImage大小的方法,如下所示:
- (UIImage *)resizedImageWithContentMode:(UIViewContentMode)contentMode
bounds:(CGSize)bounds
interpolationQuality:(CGInterpolationQuality)quality {
CGFloat horizontalRatio = bounds.width / self.size.width;
CGFloat verticalRatio = bounds.height / self.size.height;
CGFloat ratio;
switch (contentMode) {
case UIViewContentModeScaleAspectFill:
ratio = MAX(horizontalRatio, verticalRatio);
break;
case UIViewContentModeScaleAspectFit:
ratio = MIN(horizontalRatio, verticalRatio);
break;
default:
[NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %d", contentMode];
}
...UIViewContentMode似乎引用了一个整数,所以我不确定这个警告:
typedef NS_ENUM(NSInteger, UIViewContentMode) {
UIViewContentModeScaleToFill,
UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent
UIViewContentModeScaleAspectFill, ... 我怎样才能摆脱这个警告,它似乎是不正确的?异常中的NSLog正确吗?
发布于 2013-12-08 22:22:46
您可以将NSInteger UIViewContentMode转换为如下所示的int:
[NSException raise:NSInvalidArgumentException format:@"Unsupported content mode: %d", (int)contentMode];https://stackoverflow.com/questions/20459887
复制相似问题