我在使用来自相机胶卷的图像馈送的 UIView 时遇到问题。

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

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
如果(信息){
{
[artView removeFromSuperview];
艺术 View = 零;
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/

10-10 16:44