UICloudSharingController在Xcode 11中显示无限活动指示 [英] UICloudSharingController shows infinite activity indicatory in Xcode 11

查看:165
本文介绍了UICloudSharingController在Xcode 11中显示无限活动指示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下代码将UICloudSharingController导入到快速UI中,但是在第一次集成时,它仅显示一个永不停止的活动指示器,然后在第二次显示时(通过.sheet),没有活动指示器。第一次使用时,我可以看到右上角带有活动指示器的关闭按钮。对于任何反馈,我们都表示感谢。

I have the following code to import the UICloudSharingController into swift UI but when integrated the first time up it just shows an activity indicator that never stops and then the second time it is presented (via .sheet), there is no activity indicator. The first time up I can see the close button to the top right corder with activity indicator. Any feedback would be appreciated.

struct CloudSharingController: UIViewControllerRepresentable {
    typealias UIViewControllerType = UICloudSharingController

    func makeCoordinator() -> Coordinator {
        Coordinator(self)
    }

    class Coordinator: NSObject, UICloudSharingControllerDelegate {
        func cloudSharingController(_ csc: UICloudSharingController, failedToSaveShareWithError error: Error) {
            print("asdf")

        }

        func itemTitle(for csc: UICloudSharingController) -> String? {
            return "item title for sharing TTT"
        }

        var parent: CloudSharingController

        init(_ cloudSharingController: CloudSharingController) {
            self.parent = cloudSharingController
        }
    }


    var share: CKShare? = nil
    var container: CKContainer = CKContainer.default()

    var firsTimeBlock: ((UICloudSharingController, @escaping (CKShare?, CKContainer?, Error?) -> Void) -> Void)? = nil

    func makeUIViewController(context: UIViewControllerRepresentableContext<CloudSharingController>) -> CloudSharingController.UIViewControllerType {

        let result: UICloudSharingController!
        if let validFirstBlock = firsTimeBlock {
            return UICloudSharingController(preparationHandler: validFirstBlock)
        } else if let validShare = self.share {
            return UICloudSharingController(share: validShare,
                                            container: container)
        } else {
            fatalError()
        }
        result.availablePermissions = [.allowReadWrite]
//        result.popoverPresentationController?.sourceView = AccountsView
        result.delegate = context.coordinator

        return result
    }

    func updateUIViewController(_ uiViewController: CloudSharingController.UIViewControllerType, context: UIViewControllerRepresentableContext<CloudSharingController>) {

    }
}


推荐答案

我发现了可以在此处找到的解决方法:

I found a work around which could be found in here:

https://gist.github.com/arashkashi/bcffde1e35c7e406de52d9dff0127d41

解决方案brief包含一个视图控制器包装,该包装包含一个 UICloudSharingController 的实例作为子视图控制器。

The solution in brief includes a view controller wrapper which contains an instance of UICloudSharingController as a child view controller.

UICloudSharingController 在没有 CKShare ,另一个已经将 CKShare 推送到CloudKit的位置。我观察到前一个初始化器提供了一个永无止境的活动指示器。因此,我的工作是手动将没有参与者的共享推送给第二个初始化的 UICloudSharingController

UICloudSharingController has two initialized one when there is no CKShare and another one where you already have a CKShare pushed to the CloudKit. I observed that the former initializer gives a never ending activity indicator. So What I did I manually pushed the share with no participants and then provided the empty share to the second initialized of UICloudSharingController.

这就是包装控制器应具有以下行的原因:

This is the reason why the wrapper controller should have this line:

var share: CKShare? = nil

这篇关于UICloudSharingController在Xcode 11中显示无限活动指示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆