I am developing a simple IOS application using swift. In my application I need to open new controller programatically from another controller. So I added another scene to the storyboard.
Then I added a new class for new controller which is inheriting from the UIViewController. This is the code for new controller
import UIKit
class ReplayController: UIViewController {
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.
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
Then, I tried to open the new controller view (ReplayController) from the main controller like this in code.
func gameOver()
{
let replayController = ReplayController()
present(replayController, animated: true, completion: nil)
}
When I call that function, it just pops up the blank screen. Nothing appear on the screen. What is wrong and how can I solve it?