Search code examples
iosswiftstoryboardxcode7

iOS App Goes to Black Screen


I am using a Launch Screen storyboard as well as a Main storyboard in my Swift app. Sometimes the app will show the launch storyboard and then go to a black screen. Other times it correctly goes to the Main storyboard entry point. It almost seems like it is build-dependent in that if I clean and rebuild a few times, a build pop out that behaves properly. Any ideas what may be causing this?

To add some clarification:

  • The SplashScreen.storyboard is set in the target settings (good question).
  • This happens both on real devices and in simulator BUT NOT ALWAYS.
  • I am not doing any networking (synchronous or otherwise) in this stage
  • The blackout seems to happen only when transitioning to one specific view
  • The code for the view's viewWillDisplay and such executes even when blacked out, just nothing VISIBLE is displayed

This might help: I put in the following code in the offending view:

override func viewDidAppear(animated: Bool) {
    print(self.view.layer.bounds.width);
    print(self.view.layer.bounds.height);

}

When the black screen issue occurs, I get 260 and 17. When the view presents correctly, I get the 5s (simulator) dimensions of 320 and 568. Does that help anyone help me?


Solution

  • I finally solved this. After weeks of battling it and trying everything from ripping ALL of my code out, it turns out that the view outlet for my view in the storyboard had become double-linked to both "View" and one of my text fields in that view. Like this:

    enter image description here

    I have since deleted the linkage to the text field, but show the correct linkage here:

    enter image description here

    Interestingly, I am unable to reproduce this accidental connection in the UI, so I am not sure how that even happened. Anyway, I hope this helps others that might come across this.