【发布时间】:2017-07-29 06:17:57
【问题描述】:
我在 Main.storyboard 顶部有一个视频帧,我将 ScrollView 和 TextView 放在它下面,现在我的问题是 ScrollView 在所有设备上的位置不同。
例如,在 iPhone 7 Plus 中它的位置是正确的,但在 iPhone SE 中它是不同的同一 iPad。
这是我的 ViewController.swift 代码:
import UIKit
import AVFoundation
import AVKit
class ViewController: UIViewController {
let playerController = AVPlayerViewController()
var player:AVPlayer?
@IBOutlet weak var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
let videoString:String? = Bundle.main.path(forResource: "m9", ofType: ".mov")
playerController.player = player
self.addChildViewController(playerController)
let screenSize = UIScreen.main.bounds.size
let videoFrame = CGRect(x: 0, y: 30, width: screenSize.width, height: (screenSize.width * 9) / 16 )
playerController.view.frame = videoFrame
self.view.addSubview(playerController.view)
player?.play()
然后我尝试将 ScrollView 链接到视频帧:
let frame1 = CGRect(x: 0, y: 350 + videoFrame.height , width: screenSize.width, height: screenSize.height)
textView.frame = frame1
【问题讨论】:
-
为什么空行和与您的问题无关的内容?