How to hide share button in QLPreviewController using swift?

前端 未结 7 2112
无人共我
无人共我 2021-01-06 02:40

I\'m using the below code to use QLPreviewcontroller to show some documents in my app,

let ql = QLPreviewController()
ql.dataSource = self
//ql.navigationIte         


        
7条回答
  •  花落未央
    2021-01-06 03:01

    Swift 5 Solution:

    Subclass QLPreviewController:

    final class CustomQLPreviewController: QLPreviewController {
        override func viewDidLoad() {
            super.viewDidLoad()
            navigationItem.rightBarButtonItem = UIBarButtonItem()
        }
    
        override func viewDidAppear(_ animated: Bool) {
            super.viewDidAppear(animated)
            (children[0] as? UINavigationController)?.setToolbarHidden(true, animated: false)
        }
    
        override func viewDidLayoutSubviews() {
            super.viewDidLayoutSubviews()
            (children[0] as? UINavigationController)?.setToolbarHidden(true, animated: false)
        }
    }
    

    then present this subclass where you want like this:

    let previewController = QLVideoController()
    present(controller, animated: true, completion: nil)
    
    • Using this method you will se share button for moments

提交回复
热议问题