“interfaceOrientation” is deprecated in iOS 8, How to change this method Objective C

后端 未结 5 1235
花落未央
花落未央 2020-12-07 19:39

I have downloaded a simpleCamera view from Cocoa Controls which use this method

- (AVCaptureVideoOrientation)orientationForConnection
{
    AVCaptureVideoOri         


        
5条回答
  •  感情败类
    2020-12-07 20:24

    Since iOS8, Apple recommends to use TraitCollections (Size Classes) instead of interfaceOrientation.

    Moreover, since iOS 9 and the new iPad feature "Multitasking", there are some cases where the device orientation doesn't fit with the window proportions! (breaking your application UI)

    So you should also be very careful when using Regular Size Classes because it will not necessary take up the whole iPad screen.

    Sometimes TraitCollections doesn't fill all your design needs. For those cases, Apple recommends to compare view's bounds :

    if view.bounds.size.width > view.bounds.size.height {
        // ...
    }
    

    I was quite surprised, but you can check on the WWDC 2015 video Getting Started with Multitasking on iPad in iOS 9 at 21'15.

    Maybe you're really looking for the device orientation and not for the screen or window proportions. If you care about the device camera, you should not use TraitCollection, neither view bounds.

提交回复
热议问题