class model: NSObject {
var title: String = ""
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "itemCell") as! itemTableViewCell
let person = items[indexPath.row]
cell.itemLabel.text = person.value(forKey: "name") as? String
m.title = cell.itemLabel.text!
print(m.title)
return cell
}
class textViewController: UIViewController {
@IBOutlet var textView: UITextView!
override func viewDidLoad() {
super.viewDidLoad()
let V = ViewController()
textView.text = V.m.title
}
}
图片看这里
答案 0 :(得分:0)
您必须使用以下方法将字符串传递给新的视图控制器:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "AdYourIdentifierFromStoryboardHere"
{
if let destinationVC = segue.destinationViewController as? textViewController {
destinationVC.title = title
}
}
}
这篇文章将帮助您http://www.codingexplorer.com/segue-swift-view-controllers/