首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >上传后的iOS UIImagePickerController结果图像方向

上传后的iOS UIImagePickerController结果图像方向
EN

Stack Overflow用户
提问于 2011-03-25 09:41:18
回答 16查看 141K关注 0票数 346

我正在iOS 3.1.3 iPhone上测试我的iPhone应用程序。我正在使用UIImagePickerController选择/捕获图像

代码语言:javascript
复制
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[imagePicker setDelegate:self];
[self.navigationController presentModalViewController:imagePicker animated:YES];
[imagePicker release];



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    self.image = [info objectForKey:UIImagePickerControllerOriginalImage];
    imageView.image = self.image;
    [self.navigationController dismissModalViewControllerAnimated:YES];
    submitButton.enabled = YES;
}

然后,我使用ASI类将其发送到我的web服务器:

代码语言:javascript
复制
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:[NSURL URLWithString:@"http://example.com/myscript.php"]];
[request setDelegate:self];
[request setStringEncoding:NSUTF8StringEncoding];
[request setShouldContinueWhenAppEntersBackground:YES];
//other post keys/values
[request setFile:UIImageJPEGRepresentation(self.image, 100.0f) withFileName:[NSString stringWithFormat:@"%d.jpg", [[NSDate date] timeIntervalSinceNow]] andContentType:@"image/jpg" forKey:@"imageFile"];
[request startAsynchronous];

问题:当我拿着iphone拍照时,照片会被上传到服务器上,看起来就像你所期望的那样。当拿着手机在人像中拍照时,图像被上传并查看,就像它已经旋转了90度一样。

我的应用程序被设置为只在纵向模式下工作(颠倒和常规)。

如何让图片在上传后始终显示正确的方向?

在UIImageView中显示的图像看起来是正确的(直接在拍摄照片之后),但在服务器上查看时情况并非如此。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5427656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档