【发布时间】:2015-05-29 06:35:10
【问题描述】:
我尝试了很多解决方案,但都没有奏效
这是我在做什么:
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker.modalPresentationStyle = UIModalPresentationCurrentContext;
//imagePicker.allowsEditing = YES;
NSOperatingSystemVersion ios8_0_0 = (NSOperatingSystemVersion){8, 0, 0};
//This was suggested in answer of some question of stackoverflow
if ([[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:ios8_0_0])
{
if([[UIDevice currentDevice]orientation] == UIDeviceOrientationFaceUp)
{
if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft)
{
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeRight] forKey:@"orientation"];
}
else
{
[[UIDevice currentDevice]setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];
}
}
}
self.imagePickerController = imagePicker;
[self presentViewController:self.imagePickerController animated:YES completion:nil];
}
当上述方法不起作用时,我在保存图片时尝试了其他方法
NSData *imgPngData = UIImagePNGRepresentation([info objectForKey:UIImagePickerControllerOriginalImage]);
UIImage *image = [UIImage imageWithData:imgPngData];
imgPngData = UIImagePNGRepresentation(image);
[_profilePicture setImage:[UIImage imageWithCGImage:[image CGImage] scale:1.0 orientation:UIImageOrientationUp]];
但对行为没有影响。这就是我正在拍摄这张照片的情况。
这就是我的 imageView 上出现的内容
请提出一些建议。提前感谢大家。
【问题讨论】:
标签: ios objective-c iphone uiimageview orientation