ios - 横向,半 View 。 swift

标签 ios image swift view

我的应用在纵向模式下运行良好,但当我转向横向模式时,我在半 View 中看到白色方 block 。

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
}

最佳答案

当父 View 的边界发生变化时,您需要调整 moviePlayer 的大小。

一个解决方案是移动这条线:

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

进入 viewWillLayoutSubviews(如果这是一个 View Controller 子类)或 layoutSubviews(如果这是一个 View 子类)。

另一种是使用自动布局而不是手动布局。

关于ios - 横向,半 View 。 swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27305921/

相关文章:

html - 图片上方或下方

ios - Collection View 的全屏 View

ios - 更新另一个类别 objective-c 的变量

ios - 当我们从 View 中删除第三个按钮时,我们如何增加两个按钮的宽度

带有通知的 iOS Swift 'message sent to deallocated instance'

android - 删除图像按钮填充 (Android)

html - CSS 图像未正确对齐

ios - TableView 没有附加新数据

swift - collectionViewCells 到 collectionView 位置 x :0, y:0

iphone - 使用 Storyboard在 ios 上的 View 之间传递值的问题