View Controller does not load storyboard view

I am new to iOS development. I have a panel with two view controllers, I associate them with the UIViewController classes, it works when I try to load a second class from the first class (for example, the splash screen enters the main menu), but then in the β€œmenu” there is no view from the storyboard . It loads a black screen. I assigned the viewcontroller class in the right sidebar of the storyboard and colored the screen red to see if it loads the class, but if I take the color red, it will load the black screen, not the desired screen from the storyboard.

Screen 1 (Splash):

func switchScreen() {

    let secondViewController:vcMainLogin = vcMainLogin()
    self.presentViewController(secondViewController, animated: true, completion: nil)

}

override func viewDidLoad() {
    super.viewDidLoad()
    NSTimer.scheduledTimerWithTimeInterval(1.0, target: self, selector: "switchScreen", userInfo: nil, repeats: false)    

}

Screen 2 (login / menu):

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.redColor()
    // Do any additional setup after loading the view.
}

It loads because the screen color turns red, but when I remove it, it loads in black, not the screen from the storyboard.

+4
2

, . storyboardID (view β†’ utilities β†’ ). "VC2" "MainStoryboard".

let mainStoryboard = UIStoryboard(name: "MainStoryboard", bundle: NSBundle.mainBundle())
let vc : UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("VC2") as UIViewController

objective-c

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"mainStoryboard" bundle:[NSBundle mainBundle]];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"VC2"];
+12

. , , mcMainLogin, , nib . , ().

, - Swift , .

, . , , , 90+% nib/xib.

0

Source: https://habr.com/ru/post/1545490/


All Articles