添加滾動型我對Main.storyboard頂部的視頻幀,我把滾動型用的TextView下的是,我現在的問題是滾動型是不是在所有設備上的同一位置。下的視頻幀
例如,在iPhone 7加上它在正確的位置,但在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()
然後我試圖了滾動鏈接到視頻幀:
let frame1 = CGRect(x: 0, y: 350 + videoFrame.height , width: screenSize.width, height: screenSize.height)
textView.frame = frame1
爲什麼空行和物品,無關你的問題? –