I have 2 view controller.
1. ViewController (VC)
2. WebViewController (WVC)
In VC I click on a button and WVC is shown. After successfully completing all tasks in WVC, I want to show VC and execute a particular function in VC.
Now, Storyboard contains some objects and add to VC using click and drag.
Initially, it has some values(not nil).
I Click on button, WVC is pushed, After completing all task in WVC,
VC is pushed.
Now some values in VC is nil.
error,welcome (UILabel
, UIView
) is nil...
And also is want to call a function in VC.
How it is possible.?
Code
ViewController.swift
class LoginController:UIViewController,UITextFieldDelegate{
@IBOutlet weak var password: UITextField!
@IBOutlet weak var username: UITextField!
@IBOutlet weak var error: UILabel!
@IBOutlet weak var welocome: UILabel!
......
@IBAction func BtnClicked(sender: AnyObject) {
let webViewCnt = self.storyboard!.instantiateViewControllerWithIdentifier("WebViewController") as UIViewController
self.navigationController?.pushViewController(webViewCnt, animated: true)
}
func doSomeProcess(){
}
}
WebViewController.swift
class WebViewController: UIViewController, UITextFieldDelegate,UIWebViewDelegate {
override func viewDidLoad() {
super.viewDidLoad()
webView.delegate = self
self.start()
}
func start(){
---- do some process ----
dispatch_async(dispatch_get_main_queue(), { () -> Void in
let ViewCont = self.storyboard!.instantiateViewControllerWithIdentifier("LoginController") as UIViewController
self.navigationController?.pushViewController(ViewCont, animated: true)
ViewController().doSomeProcess() // call viewcontroller doSomeProcess() function
}
})
}
}