我在使用相机胶卷中的图像进行UIView时遇到了问题 .
当我选择以纵向模式拍摄的照片时,视图总是将图像拉得太高,但是当我旋转设备时,图像被拉伸得很好 .
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if(info){
{
[artView removeFromSuperview];
artView = nil;
artView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
artView.image = [info objectForKey:UIImagePickerControllerOriginalImage];
artView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
artView.contentMode = UIViewContentModeScaleAspectFill;
[self.contentView addSubview:artView];
任何帮助表示赞赏 .
2 回答
如果其他人仍然遇到此问题,请尝试在contentMode之后设置图像 .
你的代码看起来很好,除了它泄漏,你有太多的开口括号和没有关闭括号 .
您可能希望它看起来像这样:
UIViewContentModeScaleAspectFill
不应该拉伸图像 . 它应该剪辑它 . 也许UIViewContentModeScaleAspectFit
正是您要找的?