bevy / photo-editor

Photo editor with a lot of cool features
MIT License
882 stars 336 forks source link

Problems when using with ipad #59

Open jamesrv43 opened 5 years ago

jamesrv43 commented 5 years ago

fix bug in ipad

PhotoEditor+Controls.swift line at 88

@IBAction func shareButtonTapped(_ sender: UIButton) {
        //        let activity = UIActivityViewController(activityItems: [canvasView.toImage()], applicationActivities: nil)
        //        present(activity, animated: true, completion: nil)
        //
        print("shareButtonTapped")
        let objectsToShare = [canvasView.toImage()]
        let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
        activityVC.title = "Share One"
        activityVC.excludedActivityTypes = []

        activityVC.popoverPresentationController?.sourceView = self.view
        activityVC.popoverPresentationController?.sourceRect = sender.frame

        self.present(activityVC, animated: true, completion: nil)

    }

CropViewController.swift line at 148

func constrain(_ sender: UIBarButtonItem) {
        let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        if let popoverController = actionSheet.popoverPresentationController {
            popoverController.barButtonItem = sender
            popoverController.permittedArrowDirections = .down
        }
0xWDG commented 5 years ago

What is the bug?

0xWDG commented 5 years ago

If it crashes try:

func constrain(_ sender: UIBarButtonItem) {
        let actionSheet = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet)
        if let popoverController = actionSheet.popoverPresentationController {
            ///popoverController.barButtonItem = sender
            popoverController.popoverPresentationController?.sourceView = sender
popoverController.permittedArrowDirections = .down
        }

Disclaimer: this code is untested, I’m browsing from my phone, but maybe it can help.