代码之家  ›  专栏  ›  技术社区  ›  Olli

显示带有广播用户界面扩展的用户界面(可能是故事板)

  •  0
  • Olli  · 技术社区  · 7 年前

    显然,一旦从选择器视图中选择了扩展,则应加载广播UI扩展,而另一个在广播开始后接收数据,我在第一次尝试创建一个视图,创建一个故事板,并给它一个自定义类,该类与广播UI扩展的类相同,但是当我从picker视图中单击扩展时,我立即得到了错误 The user declined application recording (不确定我是否遗漏了任何步骤),在没有故事板的情况下也会出现同样的错误,我尝试了 print() 在里面 override func viewDidLoad() 在调试区域中没有日志,所以我甚至不知道它是否被加载。

    func userDidFinishSetup() )然后开始广播。如果可以在应用程序中直接启动广播,而无需UI,我也会接受 Replaykit docs 我看到一个 startBroadcast 我认为可以实现这个功能,得到了一个 broadcastInvalidSession = -5808 错误,表示我“试图在没有先前会话的情况下启动广播”。非常感谢您的帮助,谢谢。

    广播用户界面视图控制器

    import ReplayKit
    
    class BroadcastSetupViewController: UIViewController {
        override func viewDidLoad() {
            super.viewDidLoad()
            print("WASSUP?");
        }
    
        // Call this method when the user has finished interacting with the view controller and a broadcast stream can start
        func userDidFinishSetup() {
            print("GET IN!!!");
            // URL of the resource where broadcast can be viewed that will be returned to the application
            let broadcastURL = URL(string:"http://apple.com/broadcast/streamID")
    
            // Dictionary with setup information that will be provided to broadcast extension when broadcast is started
            let setupInfo: [String : NSCoding & NSObjectProtocol] = ["broadcastName": "example" as NSCoding & NSObjectProtocol]
    
            // Tell ReplayKit that the extension is finished setting up and can begin broadcasting
            self.extensionContext?.completeRequest(withBroadcast: broadcastURL!, setupInfo: setupInfo)
        }
    
        func userDidCancelSetup() {
            let error = NSError(domain: "YouAppDomain", code: -1, userInfo: nil)
            // Tell ReplayKit that the extension was cancelled by the user
            self.extensionContext?.cancelRequest(withError: error)
        }
    }
    
    
    0 回复  |  直到 7 年前
        1
  •  3
  •   Olli    7 年前

    因此,我联系了苹果技术支持部门(遗憾的是),他们建议我在广播用户界面扩展的info.plist中添加“NSExtensionMainStoryboard”,类似于Greg的回答,当这不起作用时,我发送了我的代码,我们发现我还必须从阻止它加载的同一位置删除“NSExtensionPrincipalClass”键,之后它工作正常。

        2
  •  1
  •   Javid    7 年前

    在NSExtension字典下,您应该添加一个名为“NSExtensionMainstryBoard”的键,该值应该是故事板ie的名称-“MainInterface”

    您是否能够设置在扩展中调用的断点?