【发布时间】:2018-05-16 08:38:34
【问题描述】:
要分享图像,我将其滑出屏幕。
现在发生的事情是:
- 我刷图
- 它展示了 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
}
打印出来看看发生了什么。 这是我的第一个应用程序。 谢谢你的帮助。
【问题讨论】:
标签: ios swift xcode animation uiactivityviewcontroller