import Foundation
protocol ChangeTextDelegate{
func changeLableValue(newString:String)
}
class OtherVC: UIViewController {
var delegate : ChangeTextDelegate?
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
@IBAction func otherButtonClick(sender: UIButton) {
delegate!.changeLableValue("这是第二个")
self.dismissViewControllerAnimated(true) { () -> Void in
}
class ViewController: UIViewController,ChangeTextDelegate {
func changeLableValue(newString: String) {
lable.text=newString
@IBOutlet weak var lable: UILabel!
@IBOutlet weak var btnClick: UIButton!
@IBAction func buttonClick(sender: UIButton) {
let storyBoard = UIStoryboard(name: "Main",bundle: nil)
let otherVc :OtherVC = storyBoard.instantiateViewControllerWithIdentifier("OtherVC") as! OtherVC
otherVc.delegate=self
self.presentViewController(otherVc,animated: true) { () -> Void in
}