Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crash in iPad when we tap(Long press) on image viewer in full screen mode #201

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ImageViewer/Source/GalleryViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -676,16 +676,31 @@ open class GalleryViewController: UIPageViewController, ItemControllerDelegate {
guard let image = item.image else { return }
let activityVC = UIActivityViewController(activityItems: [image], applicationActivities: nil)
self.present(activityVC, animated: true)
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
self.prepareForIpad(source: self.view, to: activityVC)
}

case (_ as VideoViewController, let item as VideoView):
guard let videoUrl = ((item.player?.currentItem?.asset) as? AVURLAsset)?.url else { return }
let activityVC = UIActivityViewController(activityItems: [videoUrl], applicationActivities: nil)
self.present(activityVC, animated: true)
if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.pad {
self.prepareForIpad(source: self.view, to: activityVC)
}

default: return
}
}

fileprivate func prepareForIpad(source: UIView, to activityVC: UIActivityViewController) {

if let popOver = activityVC.popoverPresentationController {
popOver.sourceView = source
popOver.sourceRect = CGRect(x: source.bounds.midX, y: source.bounds.midY, width: 0, height: 0)
popOver.permittedArrowDirections = []
}
}

public func itemController(_ controller: ItemController, didSwipeToDismissWithDistanceToEdge distance: CGFloat) {

if decorationViewsHidden == false {
Expand Down