Code used to work with Swift 1 but now does not and here is my issue. (did check other questions but this is slightly different, and enough so that the other solututions did not work.
So I am trying to present a logon screen which I do as follows
and it works fine, the user enters in their username and password. I then programmatically check they can log in and all still good and do the unwind as follows:
self.performSegueWithIdentifier("unwindGoToTeamPage", sender: self)
But the following code does not fire even though the func is called. I know that because I had a print statement in their for debuging and it shows on the console:
@IBAction func unwindGoToTeamPage(sender: UIStoryboardSegue){
print("In here")
self.performSegueWithIdentifier("goToTeamPage", sender: self)
}
Now I know its related to the same reason that at the start of the ViewController life cycle you can not call a
self.performSegueWithIdentifier("goToTeamPage", sender: self)
as it wont work in the
override func viewDidLoad() {
super.viewDidLoad()
}
or the
override func viewWillAppear(animated: Bool) {
}
but only in the
override func viewDidAppear(animated: Bool) {
if appDelegate.tkData[0] == "1"
{
self.performSegueWithIdentifier("goToTeamPage", sender: self)
}
}
In Swift 1 and Objective-C I used to put in a timer and all was good but that no longer works and I prefer to put in a solid solution that is not a hack. I think the solution involves waiting till the logon viewcontroller is completely dismissed but not sure the correct way to achieve it.
Could a dispatch to the main queue be an option. I will try that while I wait if someone has an answer and post an update. I also noted it works just fine on a iPhone or iPod but its the iPad where the issue is unsolved.
Appreciate any pointers to solve this problem. Thanks
Update, Yes I did try the UITextField solutions but that appears not to be the issue in this instance. I am slowly identifying the issue as one view controller not yet finished before the
self.performSegueWithIdentifier("goToTeamPage", sender: self)
fires.
I also apologies that i failed to mention the console message which is: Warning: Attempt to present <new view controller> on <current view controller> whose view is not in the window hierarchy!
So I see my issue is as needing to sort of run the logon viewcontroller in such a way as to have the orignial viewcontroller get a message that the logon view conntroller has finished and only then fire the
self.performSegueWithIdentifier("goToTeamPage", sender: self)
SO is there are way to get a call back of some sort to tell the original view controller that the child view controller has completely finished so I can then call the next function only once the child view controller is finished.
Thanks for any help on this.