作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我在使用 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/
我是一名优秀的程序员,十分优秀!