Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以编程方式将iphone中的UIImage比率更改为fb cover_Iphone_Objective C_Ios_Xcode_Facebook - Fatal编程技术网

以编程方式将iphone中的UIImage比率更改为fb cover

以编程方式将iphone中的UIImage比率更改为fb cover,iphone,objective-c,ios,xcode,facebook,Iphone,Objective C,Ios,Xcode,Facebook,我正在从图像选取器中选取一张图像,然后我想更改该图像作为facebook封面的比例。我有一张图片,假设它的分辨率是640宽,480高,我想把它换成facebook封面(851像素宽,315像素高),我将如何在iphone上编程实现这一点 查看此页了解封面图片的详细信息 谢谢 } 点击此链接了解更多详细信息 } 点击此链接了解更多详细信息。在contentMode中我将传递什么?UIViewContentMode指定视图在其大小更改时如何调整其内容。类型定义枚举{UIViewContentMode

我正在从图像选取器中选取一张图像,然后我想更改该图像作为facebook封面的比例。我有一张图片,假设它的分辨率是640宽,480高,我想把它换成facebook封面(851像素宽,315像素高),我将如何在iphone上编程实现这一点 查看此页了解封面图片的详细信息 谢谢

}

点击此链接了解更多详细信息

}


点击此链接了解更多详细信息。

在contentMode中我将传递什么?UIViewContentMode指定视图在其大小更改时如何调整其内容。类型定义枚举{UIViewContentModeScaleToFill、UIViewContentModeScaleSpectFit、UIViewContentModeScaleSpectFill、UIViewContentModerDraw、UIViewContentModeCenter、UIViewContentModeTop、UIViewContentModeBottom、UIViewContentModeLeft、UIViewContentModerTopLeft、UIViewContentModerTopRight、UIViewContentModerModeBottomLeft,UIViewContentModeBottomRight,}此处的apple文档:我将在contentMode中传递什么?UIViewContentMode指定视图在其大小更改时如何调整其内容。typedef enum{UIViewContentModeScaleToFill、UIViewContentModeScaleSpectFit、UIViewContentModeScaleSpectFill、UIViewContentModerDraw、UIViewContentModeCenter、UIViewContentModeTop、UIViewContentModeBottom、UIViewContentModeLeft、UIViewContentModerTopLeft、UIViewContentModerTopRight、UIViewContentModerModeBottomLeft,UIViewContentModeBottomRight,}苹果文档在此:
 Use this Method to Resize the image according to the given content mode, taking into account the image's orientation...

- (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];
}

CGSize newSize = CGSizeMake(self.size.width * ratio, self.size.height * ratio);

return [self resizedImage:newSize interpolationQuality:quality];