【问题标题】:How to use ALCameraViewController library in an Objective C project如何在 Objective C 项目中使用 ALCameraViewController 库
【发布时间】:2017-12-31 23:19:02
【问题描述】:

文档说要在 swift 中使用它:

        let cameraViewController = CameraViewController { [weak self] image, asset in
        // Do something with your image here.
        self?.dismiss(animated: true, completion: nil)
    } 
present(cameraViewController, animated: true, completion: nil)

但我不知道如何将其转换为 Objective C。

【问题讨论】:

    标签: ios objective-c swift camera


    【解决方案1】:

    这只是看起来很聪明的代码,因为他在 CameraViewController 的初始化程序中获得了 Swift 默认值。 Objective-C 不支持默认值,所以你需要提供它们。来源是right here

    类似这样的:

    croppingParameters: CroppingParameters = CroppingParameters(), 允许图书馆访问:布尔=真, 允许SwapCameraOrientation:布尔=真, allowVolumeButtonCapture: Bool = true, 完成:@escaping CameraViewCompletion

    __weak typeof(self) weakSelf = self;
    CameraViewController *cameraViewController = [[CameraViewController alloc] 
        initWithCroppingParameters:[CroppingParameters new]
        allowsLibraryAccess: YES
        allowsSwapCameraOrientation: YES
        allowVolumeButtonCapture: YES
        completion: ^(UIImage *image, PHAsset *asset) {
            [weakSelf dismissViewControllerAnimated:YES completion:nil];
        }];
    
    [self presentViewController:cameraViewController animated:YES completion:nil];
    

    但由于 ALCamera 项目似乎不太关心 Objective-C,因此可能不会完全支持它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-09-20
      • 2023-03-22
      • 2012-02-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多