to share an image, i swipe it off screen.
What's happening now is:
if i cancel the activity:
what i need:
How can i do this ?
here is my code:
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
}
prints are there to see what's happening. it' my first app. thank you for your help.
problem is solved.
in the moveView
method, i wrote center.y -= 1
to move the view. ie an iteration over a desired range.
now i do:
UIView.animate(withDuration: 0.5) {
self.grids.transform = CGAffineTransform(translationX: 0, y: -self.view.frame.height)}
it works as expected.