尝试将变量从viewcontroller.swift上的文本输入传递到第二个视图页面(view2)。将string()作为输入时遇到问题。这就是我所拥有的:
import Foundation
import AVFoundation
import UIKit
import AVKit
class View2 : UIViewController {
var PlayerViewController = AVPlayerViewController()
var PlayerView = AVPlayer()
override func viewDidLoad() {
super.viewDidLoad()
}
let fileURL = NSURL (fileURLWithPath: String())
PlayerView = AVPlayer (URL: srcURL)
PlayerViewController.player = PlayerView
self.presentViewController(PlayerViewController, animated: true){
self.PlayerViewController.player?.play()
}
}
答案 0 :(得分:0)
将TextView从故事板拖到View Controller swift文件中作为Outlet
并为其命名,例如
@IBOutlet weak var texty: UITextField!
然后设置一个变量,例如
var yourTexty: String!
然后你做
yourTexty = texty.text