2014-12-04 64 views
1

我的應用可以在縱向方向正常工作,但當我轉向橫向模式時,我會看到白色方形槽半視圖。風景取向,半視圖。 Swift

http://screenshot.cz/22XZB/sss.png

什麼問題?電影播放器​​的

代碼

moviePlayer = MPMoviePlayerController(contentURL: stream) 
    moviePlayer.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height) 
    moviePlayer.view.sizeToFit() 
    self.view.addSubview(moviePlayer.view) 
    moviePlayer.fullscreen = true 
    moviePlayer.controlStyle = MPMovieControlStyle.Embedded 
} 
+0

顯示電影播放器​​的視圖控制器應通過'shouldAutorotate'和'supportedInterfaceOrientations'報告它支持的旋轉 – 2014-12-04 23:21:56

回答

1

您必須重新調整moviePlayer當它的父的邊界變化。

一種解決方案是移動這一行:

moviePlayer.view.frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.height) 

進入viewWillLayoutSubviews(如果這是一個視圖控制器子類)或layoutSubviews(如果這是一個視圖的子類)。

另一種方法是使用自動佈局而不是手動佈局。