Joe Joe - 1 year ago 174
Swift Question

Pushing Viewcontroller through navigation controller , Showing Black screen

I being searching this issue in stack overflow but couldn't get an exact answer to the issue, i being stuck in it for long time.
Mine issue is i'm trying to push a TestViewController through navigation controller. when i click the button the TestViewController is being load with navigation bar and the UIScreen is in black colour.

Code of TestViewController

import UIKit
class TestViewController: UIViewController {

override func viewDidLoad() {

// Do any additional setup after loading the view.

override func didReceiveMemoryWarning() {
// Dispose of any resources that can be recreated.
override func viewWillAppear(animated: Bool) {
navigationItem.title = "Test page"

Code of Button

@IBAction func secondButtonClicked(sender: AnyObject) {
buttonPressedNumber = "Two Clicked"
buttonTextColor = UIColor.magentaColor()
let a = TestViewController()
let b:UIViewController = a as UIViewController
navigationController?.pushViewController(b, animated: false)

enter image description here

Answer Source
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let resultViewController = storyBoard.instantiateViewControllerWithIdentifier("ViewController") as! ViewController
self.navigationController?.pushViewController(resultViewController, animated: true)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download