ReplayKit RPBroadcastActivityViewController iPad

ReplayKit RPBroadcastActivityViewController iPad

如何在 iPad 上显示 RPBroadcastActivityViewController。

我正在使用标准代码开始录制

   RPBroadcastActivityViewController.load { [unowned self] (broadcastActivityViewController, error) in

        // If an error has occurred, display an alert to the user.
        if let error = error {
            self.showAlert(message: error.localizedDescription)
            return
        }

        // Present vc
        if let broadcastActivityViewController = broadcastActivityViewController {

            broadcastActivityViewController.delegate = self

            // present
            self.present(...
        }
    }

在 iPhone 上工作,但在 iPad 上没有任何显示,应用程序有点冻结。我一直在查看应用商店中使用此功能的游戏,我发现了同样的问题。

例如,在 iPad 上按下直播按钮时,在 Tower Dash 游戏中没有任何内容出现,它只适用于 iPhone。

我一直在尝试使用弹出窗口演示文稿,但似乎没有任何效果。

我是不是漏掉了什么?

更新:这似乎是一个错误。即使在苹果自己的 Swift Playground 应用程序中也会发生这种情况。

更新 2:Apple 实际上已经回复了我的错误报告并告诉我我需要在 iPad 上将视图控制器呈现为像这样的弹出窗口

  UIDevice.current.userInterfaceIdiom == .pad {
       broadcastAVC.popoverPresentationController?.sourceView = view
       broadcastAVC.popoverPresentationController?.sourceRect = CGRect(x: view.bounds.midX, y: view.bounds.midY, width: 0, height: 0)
       broadcastAVC.popoverPresentationController?.permittedArrowDirections = UIPopoverArrowDirection.init(rawValue: 0) // no arrow
  }

但是它对我仍然不起作用。正如我提到的,这发生在苹果自己的 Swift Playground 应用程序上,所以它一定是一个错误。

固定:

我忘了在上面提到的代码中添加这一行

 broadcastAVC.modalPresentationStyle = .popover

iOS 10.1 beta 2 还是有同样的问题。

目前,我发现在 iPad 上呈现 RPBroadcastActivityViewController 的唯一方法是在特征集合的水平紧凑环境中呈现它。

因此,您可能需要在 select 一个支持广播的应用程序之前告诉您的用户切换到拆分视图模式,然后再切换回全屏。回到全屏后,您可以使用RPBroadcastController.startBroadcast(handler:)开始直播。

你说得对,Apple 的演示应用程序没有包含这个小细节,但这不是错误。这就是我用来让它在 iPad 上工作的方法。 iPads 需要弹出窗口来呈现视图,弹出窗口需要锚点。我选择将它锚定到 leftBarButtonItem。

if let unwrappedPreview = preview {
            unwrappedPreview.previewControllerDelegate = self

            if UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiom.phone {
                self.present(unwrappedPreview, animated: true, completion: nil)
            }
            else {
                unwrappedPreview.popoverPresentationController?.barButtonItem = self.navigationItem.leftBarButtonItem!
                unwrappedPreview.modalPresentationStyle = UIModalPresentationStyle.popover
                unwrappedPreview.preferredContentSize = CGSize(width: self.view.frame.width, height: self.view.frame.height)
                self.present(unwrappedPreview, animated: true, completion: nil)

            }
        }