Search code examples
swift3uiactivityviewcontroller

UIActivityViewController's apps won't get selected


So, I created a basic activity view controller with the most needed parameters and it gets called, as expected, BUT!

After presenting you can't tap on any item, except 'Cancel' on the bottom.

Looked around on several sites, in debug mode, etc, no results found yet.

Implementation:

func shareViaOther() {
        let body = Constants.ShareContent.title + "\n\n" + Constants.ShareContent.body
        let image = UIImage(named: Constants.ImageNames.appIcon)!
        let url = Constants.ShareContent.url!

        let items: [Any] = [body, image, url]

        let activityVC = UIActivityViewController(activityItems: items, applicationActivities: nil)
        activityVC.popoverPresentationController?.sourceView = view

        activityVC.excludedActivityTypes = [
            UIActivityType.postToWeibo,
            UIActivityType.postToTencentWeibo,
            UIActivityType.postToVimeo,
            UIActivityType.postToFlickr,
            UIActivityType.saveToCameraRoll,
            UIActivityType.assignToContact,
            UIActivityType.print,
            UIActivityType.copyToPasteboard
        ]

        present(activityVC, animated: true, completion: nil)
    }

Disclaimer: Seems like cleaning the project, reset the phone and rebuild did not make any difference..

Any help would be highly appreciated!!


Solution

  • I found the bug, here's the recap and the solution:

    Recap:

    I created an extension for common UIViewController, in which I overrode the touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) method. It has never been called, and stopped acting like I expected. It didn't allow me to select any table view cell on in table view I added to the view - in the lack of tap gesture recognizer.

    The more frustrating part was causing activity view controller deselectable, however scroller worked properly - that's were I came to realize where the problem might have been.

    Solution:

    Deleted touchesBegan(...) from the UIViewController extension, and created a BaseViewController which I inherit every single view controller from, and extended BaseViewController capabilities with that touchesBegan(...) function. Now I can select the presented apps by tapping on them. Cheers!