FirstViewController中的函数调用是 -
@IBAction func redViewAct(sender :UIButton) {
let nextview = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController1") as! ViewController1
self.navigationController?.pushViewController(nextview, animated: true)
let f1 = ViewController1()
f1.view1Show()
}
第二堂课的方法 -
@IBOutlet weak var redView: UIView!
@IBOutlet weak var blackview: UIView!
override func viewDidLoad() {
super.viewDidLoad()
}
func view1Show() {
redView.hidden = false
blackview.hidden = true
}
答案 0 :(得分:0)
尝试如下,FirstViewController,
@IBAction func redViewAct(sender :UIButton) {
let nextview = self.storyboard?.instantiateViewControllerWithIdentifier("ViewController1") as! ViewController1
nextview.flag = "showView"
self.navigationController?.pushViewController(nextview, animated: true)
}
在第二个视图中,
@IBOutlet weak var redView: UIView!
@IBOutlet weak var blackview: UIView!
var flag : String = ""
override func viewDidLoad() {
super.viewDidLoad()
if(self.flag == "showView")
{
redView.hidden = false
blackview.hidden = true
}
}
希望这会对你有所帮助。