【发布时间】:2013-12-08 22:18:37
【问题描述】:
我在 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 是否正确?
【问题讨论】:
标签: ios objective-c ios6 uiview ios7