gpt4 book ai didi

iphone - 从相机胶卷加载的图片在纵向模式下过于拉伸(stretch)

转载 作者:太空狗 更新时间:2023-10-30 04:01:28 26 4
gpt4 key购买 nike

我在使用 UIView 时遇到问题,它正在从相机胶卷中获取图像。

当我选择一张在肖像模式下拍摄的照片时, View 总是将图片拉伸(stretch)得太高,但当我旋转我的设备时,图片拉伸(stretch)得很好。

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

感谢任何帮助。

最佳答案

如果其他人仍然遇到此问题,请尝试在 contentMode 之后设置图像。

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
if (info) {
[artView removeFromSuperview];
artView = [[UIImageView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

artView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth;
artView.contentMode = UIViewContentModeScaleAspectFill;
artView.image = [info objectForKey:UIImagePickerControllerOriginalImage];

[self.contentView addSubview:artView];
[artView release];
}
}

关于iphone - 从相机胶卷加载的图片在纵向模式下过于拉伸(stretch),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6213870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com