要共享图像,我会将其从屏幕上刷下。
现在发生的是:
我刷图像
它显示UIActivityViewController
我选择一个活动
活动以模式出现
如果我取消活动:
图像在屏幕上(视图已加载)
图像移回
我需要的是:
我取消活动
图像不在屏幕上
图像移回
我该怎么做?
这是我的代码:

        let activityViewController = UIActivityViewController(activityItems: [imageToShare], applicationActivities: nil)
    self.present(activityViewController, animated: true, completion: {
        print("presented")
        //self.grids.center = self.offScreenPosition
        print("position share is \(self.grids.center)")
    })

    switch deviceOrientation {
    case "portrait":
        activityViewController.completionWithItemsHandler = {(UIActivityType: UIActivityType?, completed: Bool, returnedItems: [Any]?, error: Error?) in
            if !completed {
                print("cancelled")
                self.moveViewVertically(.backIn, range: self.verticalRange)
            }
            if completed {
                print("completed")
                self.moveViewVertically(.backIn, range: self.verticalRange)
            }
        }
    case "landscape":
        activityViewController.completionWithItemsHandler = {(UIActivityType: UIActivityType?, completed: Bool, returnedItems: [Any]?, error: Error?) in
            if !completed {
                print("cancelled")
                self.moveViewHorizontally(.backIn, range: self.horizontalRange)
            }
            if completed {
                self.moveViewHorizontally(.backIn, range: self.horizontalRange)
            }
        }
    default:
        break
    }

指纹是用来看看发生了什么。
这是我的第一个应用程序。
谢谢你的帮助。

最佳答案

是否要在activityViewController关闭之前将视图移回?您可以尝试这样做:自定义UIActivity的一个子类,然后

- (void)performActivity {
    // move your view back in
    [self activityDidFinish:YES];
}

10-07 19:51
查看更多