当前位置 : 主页 > 手机开发 > 其它 >

swift – 呈现AVPlayerViewController StatusBar使UI跳转

来源:互联网 收集:自由互联 发布时间:2021-06-11
按下按钮我正在呈现一个AVPlayerViewController: func playVideoPressed(sender: UIButton){ let videoURL = NSURL(string: "someUrl") let player = AVPlayer(URL: videoURL!) let playerViewController = AVPlayerViewController() playerView
按下按钮我正在呈现一个AVPlayerViewController:

func playVideoPressed(sender: UIButton){
  let videoURL = NSURL(string: "someUrl")
  let player = AVPlayer(URL: videoURL!)
  let playerViewController = AVPlayerViewController()
  playerViewController.player = player
  self.presentViewController(playerViewController, animated: true) {
    playerViewController.player!.play()
  }
}

此AVPlayerViewController的状态栏使当前视图控制器的UI跳转.我可以在此“presentViewController”调用中隐藏状态栏吗?

我试过包括

playerViewController.prefersStatusBarHidden()

但玩家继续显示状态栏.

谢谢

我最终只是创建了一个新的AVPlayerViewController,我从按钮按下,并在该控制器中我添加了代码:

override func prefersStatusBarHidden() -> Bool {
    return true
}

看起来像更多的代码,考虑到我只是在观看视频,但它运作顺畅.

网友评论