标签: orientation

PHP read_exif_data和调整方向

如果方向关闭,我使用以下代码旋转上传的jpeg图像.我只是对从iPhone和Android上传的图片有问题.

if(move_uploaded_file($_FILES['photo']['tmp_name'], $upload_path . $newfilename)){
            chmod($upload_path . $newfilename, 0755);
            $exif = exif_read_data($upload_path . $newfilename);
            $ort = $exif['IFD0']['Orientation'];
            switch($ort)
            {

                case 3: // 180 rotate left
                    $image->imagerotate($upload_path . $newfilename, 180, -1);
                    break;


                case 6: // 90 rotate right
                    $image->imagerotate($upload_path . $newfilename, -90, -1);
                    break;

                case 8:    // 90 rotate left
                    $image->imagerotate($upload_path . $newfilename, 90, -1);
                    break;
            }
            imagejpeg($image, $upload_path . $newfilename, 100);
            $success_message = 'Photo Successfully Uploaded';
        }else{
            $error_count++;
            $error_message = 'Error: Upload Unsuccessful<br />Please Try Again';
        }
Run Code Online (Sandbox Code Playgroud)

我在从jpeg读取EXIF数据的方式上做错了吗?它不是按照预期旋转图像.

当我运行var_dump($ exif)时会发生这种情况; …

php exif orientation

75
推荐指数
6
解决办法
9万
查看次数

iOS - UIImageView - 如何处理UIImage图像方向

是否可以设置UIImageView来处理图像方向?当我将UIImageView设置为方向为RIGHT的图像(它是来自相机胶卷的照片)时,图像会向右旋转,但我想以正确的方向显示它.

我知道我可以旋转图像数据,但它可以做得更优雅吗?

谢谢

orientation uiimageview uiimage ios

74
推荐指数
9
解决办法
10万
查看次数

如何在iOS上检测设备的方向?

我有一个关于如何在iOS上检测设备方向的问题.我不需要接收更改通知,只需要接收当前方向.这似乎是一个相当简单的问题,但我无法绕过它.以下是我到目前为止所做的事情:

UIDevice *myDevice = [UIDevice currentDevice] ;
[myDevice beginGeneratingDeviceOrientationNotifications];
UIDeviceOrientation deviceOrientation = myDevice.orientation;
BOOL isCurrentlyLandscapeView = UIDeviceOrientationIsLandscape(deviceOrientation);
[myDevice endGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)

在我看来这应该工作.我启用设备接收设备方向通知,然后询问它的方向,但它不起作用,我不知道为什么.

objective-c orientation uidevice ios

71
推荐指数
6
解决办法
10万
查看次数

检测iOS UIDevice方向

我需要检测设备何时处于纵向方向,以便我可以触发特殊动画.但我不希望我的观点自动旋转.

当设备旋转为纵向时,如何覆盖自动旋转视图?我的应用程序只需要在横向上显示它的视图,但如果我想能够检测旋转到肖像,我似乎还需要支持肖像.

objective-c orientation uidevice ios swift

70
推荐指数
2
解决办法
5万
查看次数

在Swift中获取设备方向

我想知道如何在Swift中获得当前的设备方向?我知道有一些Objective-C的例子,但我还是无法在Swift中使用它.

我试图获取设备方向并将其放入if语句中.

这是我遇到的最多问题:

[[UIApplication sharedApplication] statusBarOrientation]
Run Code Online (Sandbox Code Playgroud)

orientation ios swift

68
推荐指数
12
解决办法
7万
查看次数

获取当前界面方向的不同方法?

我知道有三种方法可以获得当前的界面方向:

  • self.interfaceOrientation
  • [[UIApplication sharedApplication] statusBarOrientation]
  • [[UIDevice currentDevice] orientation]

他们之间有什么不同?

orientation ios

63
推荐指数
2
解决办法
3万
查看次数

获取iPad的当前定位?

在给定的事件处理程序(不是"shouldAutorotateToInterfaceOrientation"方法)中,如何检测当前的iPad方向?我有一个文本字段,我必须在横向视图中设置动画(键盘出现时),但不在纵向视图中,并且想知道我在哪个方向看动画是否必要.

orientation ipad

62
推荐指数
4
解决办法
5万
查看次数

shouldAutorotateToInterfaceOrientation未在iOS 6中调用

我正在使用MGSplitViewController,我shouldAutorotateToInterfaceOrientation用来控制旋转时主视图控制器的大小.

它在iOS 5上运行良好,但在iOS 6(模拟器和iPad)shouldAutorotateToInterfaceOrientation上从未调用过.

这是一个我应该期望在iOS 6的最终版本中修复的错误或者我不知道已经改变的东西吗?

orientation ios ios6

61
推荐指数
8
解决办法
9万
查看次数

IOS 6强制设备朝向景观

我给了一个应用程序说10个视图控制器.我使用导航控制器来加载/卸载它们.

除一个以外的所有人都处于纵向模式 假设第7个VC处于景观状态.我需要它在加载时以横向呈现.

请建议在IOS 6中强制定位从纵向到横向的方法(在IOS 5中工作也很好).

以下是我 IOS 6 之前做的事情:

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    UIViewController *c = [[[UIViewController alloc]init] autorelease];
    [self presentModalViewController:c animated:NO];
    [self dismissModalViewControllerAnimated:NO];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
Run Code Online (Sandbox Code Playgroud)

呈现和解雇模态VC迫使应用程序检查其方向,因此shouldAutorotateToInterfaceOrientation被调用.

我在IOS 6中尝试过的内容:

- (BOOL)shouldAutorotate{
    return YES;
}
-(NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscape;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation{
    return UIInterfaceOrientationLandscapeLeft;
}
Run Code Online (Sandbox Code Playgroud)

在加载时,控制器保持纵向.旋转设备后,方向改变就好了.但是我需要让控制器在加载时自动旋转到横向,因此用户必须旋转设备才能正确查看数据.

另一个问题:该装置旋转回纵向后,方向变为纵向,虽然我在指定supportedInterfaceOrientations唯一的UIInterfaceOrientationMaskLandscape.为什么会这样?

此外,上述3种方法越来越被调用.

一些(有用的)数据:

  1. 在我的plist文件中,我指定了3个方向 - 所有方向都是颠倒的.
  2. 该项目是在Xcode 4.3 IOS 5中启动的.包括xib在内的所有类都是在Xcode 4.5 IOS 6之前创建的,现在我使用的是最后一个版本.
  3. 在plist文件中,状态栏设置为可见.
  4. 在xib文件中(我希望在横向中),状态栏为"无",方向设置为横向.

任何帮助表示赞赏.谢谢.

iphone objective-c orientation ios6

57
推荐指数
4
解决办法
7万
查看次数

AVCaptureVideoPreviewLayer方向 - 需要景观

我的应用只是风景.我将这样呈现AVCaptureVideoPreviewLayer:

self.previewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
[self.previewLayer setBackgroundColor:[[UIColor blackColor] CGColor]];
[self.previewLayer setVideoGravity:AVLayerVideoGravityResizeAspect];                    
NSLog(@"previewView: %@", self.previewView);
CALayer *rootLayer = [self.previewView layer];
[rootLayer setMasksToBounds:YES];
[self.previewLayer setFrame:[rootLayer bounds]];
    NSLog(@"previewlayer: %f, %f, %f, %f", self.previewLayer.frame.origin.x, self.previewLayer.frame.origin.y, self.previewLayer.frame.size.width, self.previewLayer.frame.size.height);
[rootLayer addSublayer:self.previewLayer];
[session startRunning];
Run Code Online (Sandbox Code Playgroud)

self.previewView的框架为(0,0,568,320),这是正确的.self.previewLayer记录一个(0,0,568,320)的帧,这在理论上是正确的.但是,相机显示在横向屏幕中间显示为纵向矩形,并且相机预览图像的方向错误90度.我究竟做错了什么?我需要相机预览层出现在全屏幕,在横向模式下,图像应正确导向.

avfoundation orientation ios avcapture avcapturesession

56
推荐指数
6
解决办法
5万
查看次数