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

标签 iphone objective-c uiviewcontroller

我在使用 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/

相关文章:

iphone - iOS7 容器 View 问题

iphone - 如何在 iPhone 应用程序中管理模型和 View ?

iphone - iOS 漫画阅读器 - 这是一个可行的设计吗?

iphone - 如何检查UILabel中的文本?

objective-c - NSTask 与 bash 脚本问题

ios - Swift:在与其他 View Controller 相同的上下文中呈现 View Controller ?

iphone - 如何创建比 Core Plot 生成的图表更好看的图表?

iphone - 是否有可能在结束减速之前知道最终的 UIScrollView contentOffset?

ios - 无法在实现中引用委托(delegate)协议(protocol)

ios - 如何在单元测试中调用 web 服务作为 uiviewcontroller 的一部分?