2016-09-21 32 views
1

如何在iPad上展示RPBroadcastActivityViewController。ReplayKit RPBroadcastActivityViewController iPad

我使用的是標準的代碼開始錄製在iPhone,但在iPad上沒有

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(... 
     } 
    } 

作品提出並應用一種凍結的。我一直在使用此功能的應用程序商店檢查遊戲,並且發現了相同的問題。

例如在遊戲Tower Dash上按下iPad上的實時流按鈕時不會顯示任何內容,它僅適用於iPhone。

我一直在嘗試播放popover演示文稿,但似乎沒有任何工作。

我錯過了什麼嗎?

更新:這似乎是一個錯誤。即使在蘋果自己的Swift Playground應用程序中也會發生這種情況。

UPDATE2:蘋果實際上已經回答了我的錯誤報告,並告訴我,我需要出示視圖控制器上的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 
    } 

但是它仍然does not工作對我來說。正如我所提到的,這發生在蘋果自己的Swift Playground應用程序上,所以它一定是一個bug。

修正:

忘了在上述

broadcastAVC.modalPresentationStyle = .popover 
+0

你寫了一個錯誤報告嗎? –

+0

是的,我做到了。我認爲這肯定是一個錯誤,因爲它也發生在他們自己的快速遊樂場應用程序上。還沒有從他們那裏收到回覆(28411422) – crashoverride777

+0

希望他們能儘快解決這個問題:) –

回答

1

你是對的,蘋果的演示程序不包括這個小細節,但它不是一個錯誤。這是我用它來在iPad上運行的。 iPad需要彈出窗口來呈現視圖,而彈出窗口需要錨點。我選擇將它錨定到左邊的BarButtonItem。

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) 

      } 
     } 
+0

嘿,感謝您的回答,任何想法爲什麼這不適合我?我已經這樣做了(請參閱我的問題的更新2),它仍然無法正常工作,它與我用於UIActivityControllers的代碼相同,它在那裏工作 – crashoverride777

+1

固定。我忘了添加這行代碼... modalPresentationStyle = .popover。謝謝你的幫助。 – crashoverride777

0

的iOS 10.1的β2中提到的代碼添加此行仍然有同樣的問題。

現在,我發現在iPad上呈現RPBroadcastActivityViewController的唯一方法是將其呈現在特徵集合的水平緊湊環境中。

因此,在選擇廣播支持的應用程序之前,您可能需要告訴用戶切換到分割視圖模式,然後切換回全屏。回到全屏後,您可以使用RPBroadcastController.startBroadcast(handler:)開始播放。

+0

感謝您的答案。希望蘋果很快就會修復它。 – crashoverride777