4

I am trying to preview the Images/Video/PDF in UICollectionViewCell (full screen). for PDF I am trying to use the QuickLook framework.

Here is what I am trying to do,

CollectionView

  • CollectiViewCell
  • QLPreviewController.view as subview of CollectionView.contentView

and other cells will be simple UIImageViews.
So when I scroll right/left the touches are always consumed by QLPreviewController and I am unable to navigate to next cell.

I tried adding subview after adding qlpreviewcontroller.view (to intercept touches)

The Implementation follows:

    class SampleView: UIView {
        override init(frame: CGRect) {
            super.init(frame: frame)

        }

        required init?(coder aDecoder: NSCoder) {
            fatalError("init(coder:) has not been implemented")
        }

        override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
            return nil
        }
    }
    class SCGalleryCollectionViewCell: UICollectionViewCell,UIScrollViewDelegate, QLPreviewControllerDataSource {

        var quickLookController : PreviewController!
        var scrollView : UIScrollView!
        var imageView : SCImageView!
        override init(frame: CGRect) {
            super.init(frame: frame)



                    let sampleView = SampleView()
                    sampleView.translatesAutoresizingMaskIntoConstraints = false
                    contentView.addSubview(sampleView)
                    sampleView.fillHorizontally()
                    sampleView.fillVertically()
                    sampleView.backgroundColor = UIColor.greenColor()
                    contentView.bringSubviewToFront(sampleView)

            quickLookController = PreviewController()
            quickLookController.dataSource = self




         //   quickLookController.view.frame = CGRectMake(0, 0, 100, 100)
            quickLookController.view.translatesAutoresizingMaskIntoConstraints = false
            sampleView.addSubview(quickLookController.view)
            quickLookController.view.fillVertically()
            quickLookController.view.fillHorizontally()
            quickLookController.view.userInteractionEnabled = false
            quickLookController.view.gestureRecognizers = nil

        }
}

class PreviewController: QLPreviewController, UIGestureRecognizerDelegate {

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        view.userInteractionEnabled = false
        view.exclusiveTouch = false
        view.multipleTouchEnabled = false



    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
    }

    func gestureRecognizerShouldBegin(gestureRecognizer: UIGestureRecognizer) -> Bool {
        return false
    }
    func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
        return false
    }

    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

        }
}

So my question is, how can I disable the swipe gesture on qlpreviewcontroller ?

Thanks in advance!!

CodeChanger
  • 7,953
  • 5
  • 49
  • 80
infiniteLoop
  • 2,135
  • 1
  • 25
  • 29
  • is there any solution for the above. Please let us know if you found any. I am also facing the same problem for my requirement. – sateesh May 16 '16 at 16:20

0 Answers0