ios - 关于 Apple 的 WWDC 2017 Session 506 中的代码摘录 - exifOrientationFromDeviceOrientation() 在哪里定义?

标签 ios swift wwdc apple-vision

在 session 506 的 WWDC 2017 视频中。第一个演示中有一段代码如下所示:

let exifOrientation = self.exifOrientationFromDeviceOrientation()

self 的使用。表明它应该是来自 ViewController 的属性。鉴于此 exifOrientationFromDeviceOrientation() 方法在 UIViewController 类中不存在,我认为 ViewController 符合授予该功能的协议(protocol)。有人可以指出是哪个协议(protocol)吗?

最佳答案

我强烈建议你看看https://github.com/yulingtianxia/Core-ML-Sample/blob/master/CoreMLSample/ViewController.swift这是 Core-ML-Sample 的一部分GitHub 上的项目。

var exifOrientationFromDeviceOrientation: Int32 {
    let exifOrientation: DeviceOrientation
    enum DeviceOrientation: Int32 {
        case top0ColLeft = 1
        case top0ColRight = 2
        case bottom0ColRight = 3
        case bottom0ColLeft = 4
        case left0ColTop = 5
        case right0ColTop = 6
        case right0ColBottom = 7
        case left0ColBottom = 8
    }
    switch UIDevice.current.orientation {
    case .portraitUpsideDown:
        exifOrientation = .left0ColBottom
    case .landscapeLeft:
        exifOrientation = .top0ColLeft
    case .landscapeRight:
        exifOrientation = .bottom0ColRight
    default:
        exifOrientation = .right0ColTop
    }
    return exifOrientation.rawValue
}

干杯!

关于ios - 关于 Apple 的 WWDC 2017 Session 506 中的代码摘录 - exifOrientationFromDeviceOrientation() 在哪里定义?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46413629/

相关文章:

ios - AFNetworking SessionManager 设置 HTTPHeaderField 导致错误

ios - 自动布局或自动调整大小

javascript - 使用 requestAnimationFrame 替换 $(window).on ('scroll' , function(){}); 是否安全?

ios - 自定义后退按钮在 iOS 中抛出异常

ios - 注册大量 UICollectionViewCell 类以在 UICollectionView 中重用

iOS 10 NSUserActivity,位置建议 - MKMapItem 未出现在 map 中

ios - 将自己从 Bonjour 搜索结果中排除的方法

ios - 为Swift文件的方法列表制作头文件?

ios - Firebase数据库swift的权限被拒绝

ios - 如何在具有相同Apple ID的多个设备的用户中找出 "Sign in with Apple"?