如何在RPBroadcastActivityViewController上显示iPads。
我正在使用标准代码开始录制
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(...
}
}在iPhones上工作,但在iPads上,什么都没有出现,应用程序就像冻结了一样。我一直在查看使用此功能的应用程序商店的游戏,我注意到了同样的问题。
例如,在游戏塔塔上,当按下iPads上的活动流按钮时,什么都不会显示,它只在iPhones上工作。
我一直在尝试玩流行音乐的演示,但似乎没有任何效果。
我是不是遗漏了什么?
更新:这似乎是一个bug。即使在苹果自己的Swift游乐场应用程序中,这种情况也会发生。
UPDATE2:苹果实际上已经对我的bug报告做出了回应,并告诉我,我需要将iPads上的视图控制器作为一个弹出器来呈现
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游乐场应用程序上,所以它肯定是个bug。
固定:
我忘了在上面提到的代码中添加这一行。
broadcastAVC.modalPresentationStyle = .popover发布于 2016-11-07 03:38:02
你是正确的,苹果的演示应用程序没有包括这个小细节,但它不是一个bug。这就是我用来让它在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)
}
}发布于 2016-10-08 09:52:03
iOS 10.1 beta 2仍然存在同样的问题。
目前,我发现在RPBroadcastActivityViewController上显示iPad的唯一方法是在特性集合的水平紧凑环境中显示它。
因此,在选择支持广播的应用程序之前,您可能需要告诉用户切换到拆分视图模式,然后切换回全屏。回到全屏后,您可以使用RPBroadcastController.startBroadcast(handler:)启动广播。
https://stackoverflow.com/questions/39624816
复制相似问题