Skip to content
This repository has been archived by the owner on Feb 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #7 from teambition/feature/files-name
Browse files Browse the repository at this point in the history
fix: no image name when upload to icloud
  • Loading branch information
wzxha authored May 22, 2018
2 parents eaf2a0a + 563ce6c commit a309005
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions PhotoBrowser/PhotoBrowser.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,15 +381,27 @@ extension PhotoBrowser {
}

public func defaultShareAction() {
if let image = currentImageView()?.image, let button = headerView?.rightButton {
let activityController = UIActivityViewController(activityItems: [image], applicationActivities: nil)
if let image = currentImageView()?.image, let button = headerView?.rightButton, let photos = photos {
let url = URL(fileURLWithPath: NSTemporaryDirectory().appending(photos[currentIndex].title ?? ""))
let data = UIImagePNGRepresentation(image)
do {
try data?.write(to: url)
} catch {}

let activityController = UIActivityViewController(activityItems: [url], applicationActivities: nil)
if UIDevice.current.userInterfaceIdiom == .pad {
activityController.modalPresentationStyle = .popover
activityController.popoverPresentationController?.sourceView = view
let frame = view.convert(button.frame, from: button.superview)
activityController.popoverPresentationController?.sourceRect = frame
}
present(activityController, animated: true, completion: nil)
activityController.completionWithItemsHandler = { (_, _, _, _) in
do {
try FileManager.default.removeItem(at: url)
} catch {}
}

present(activityController, animated: true)
}
}
}
Expand Down

0 comments on commit a309005

Please sign in to comment.