小编Get*_*tMe的帖子

在iOS 8中不推荐使用"interfaceOrientation",如何更改此方法目标C.

我从Cocoa Controls下载了一个使用此方法的simpleCamera视图

- (AVCaptureVideoOrientation)orientationForConnection
{
    AVCaptureVideoOrientation videoOrientation = AVCaptureVideoOrientationPortrait;
    switch (self.interfaceOrientation) {
        case UIInterfaceOrientationLandscapeLeft:
            videoOrientation = AVCaptureVideoOrientationLandscapeLeft;
            break;
        case UIInterfaceOrientationLandscapeRight:
            videoOrientation = AVCaptureVideoOrientationLandscapeRight;
            break;
        case UIInterfaceOrientationPortraitUpsideDown:
            videoOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
            break;
        default:
            videoOrientation = AVCaptureVideoOrientationPortrait;
            break;
    }
    return videoOrientation;
}
Run Code Online (Sandbox Code Playgroud)

问题是在iOS 8中不推荐使用"interfaceOrientation"但我不知道在Switch条件中替换它的方法和方法.

cocoa-touch objective-c ios

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

如何为从Photos Framework中提取的PHAsset添加分页?

我正在尝试使用Photos框架从cameraRoll获取所有照片,但它花了很多时间从cameraRoll获取所有照片.

无论如何,他们是否会加入分页?所以我可以在滚动时获取.

 var images = [UIImage]()
 var assets = [PHAsset]()

fileprivate func assetsFetchOptions() -> PHFetchOptions {
    let fetchOptions = PHFetchOptions()

    //fetchOptions.fetchLimit = 40 //uncomment to limit photo

    let sortDescriptor = NSSortDescriptor(key: "creationDate", ascending: false)
    fetchOptions.sortDescriptors = [sortDescriptor]
    return fetchOptions
}

fileprivate func fetchPhotos() {
    let allPhotos = PHAsset.fetchAssets(with: .image, options: assetsFetchOptions())

    DispatchQueue.global(qos: .background).async {
        allPhotos.enumerateObjects({ (asset, count, stop) in
            //print(count)

            let imageManager = PHImageManager.default()
            let targetSize = CGSize(width: 200, height: 200)
            let options = PHImageRequestOptions()
            options.isSynchronous = true
            imageManager.requestImage(for: asset, …
Run Code Online (Sandbox Code Playgroud)

ios swift photosframework phasset ios11

1
推荐指数
1
解决办法
837
查看次数

标签 统计

ios ×2

cocoa-touch ×1

ios11 ×1

objective-c ×1

phasset ×1

photosframework ×1

swift ×1