【问题标题】:Display UIActivityViewController as form sheet on iPad在 iPad 上将 UIActivityViewController 显示为表单
【发布时间】:2021-08-06 15:31:25
【问题描述】:

我正在尝试在不使用弹出框(即没有源视图或箭头)的情况下显示共享表。

这是我的代码,从一个基本的单视图应用开始:

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
    }

    @IBAction func didTapShare(_ sender: UIButton) {
        let activity = UIActivityViewController(activityItems: ["banana"], applicationActivities: nil)
        
        if UIDevice.current.userInterfaceIdiom == .pad {
            activity.modalPresentationStyle = .formSheet
//            activity.preferredContentSize = CGSize(width: 400, height: 400)
        }
        
        present(activity, animated: true, completion: nil)
    }
    
}

这当然会崩溃

"UIPopoverPresentationController (<UIPopoverPresentationController: 0x7fce07507900>) should have a non-nil sourceView or barButtonItem set before the presentation occurs."

但我不希望它看起来像一个弹出窗口,或者有一个箭头 - 我希望它显示为一个表单,在屏幕中间。

照片应用中的外观如下:

【问题讨论】:

    标签: ios uiactivityviewcontroller


    【解决方案1】:

    尝试设置以下

    activity.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection(rawValue: 0)
    

    【讨论】:

      猜你喜欢
      • 2020-11-09
      • 1970-01-01
      • 2014-10-27
      • 2015-06-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-10
      • 2014-01-17
      相关资源
      最近更新 更多