12

I'm using Interface Builder to make the launch image file for iOS 8. The launch image that I want is very simple (same as the Settings app, I think) - Navigation Bar at the top with an empty, Grouped TableView. No title, etc.

Note, I don't normally use Interface Builder - so the IB thing is completely new to me.

I'm trying to achieve this by adding a Navigation Bar and Table View to the View - and then setting up the constraints. The constraints (and colours) are working fine, but...

The problem: the launch image displays full screen, over the status bar. Like this:

enter image description here

How do I get both the status bar and the navigation bar?

Like I said, I'm working with the default 'UIView' you get when you select to add a Launch Screen in Xcode. So there isn't a Navigation Controller; is that the problem?

Additionally, there are some options on the UIView that seem like they should give me what I want:

enter image description here

I've tried playing around with the Status Bar options, but it's not quite working.

  • Do I need Inferred or Default?
  • I'm seeing a small offset between the launch image (status bar + navigation bar) and the actual app running, have I just positioned it incorrectly?
  • What's the purpose of the Top Bar option?
  • For the launch image that I want, do I even need to add a TableView as a subview, or can I use the background colour on the main UIView? I've tried that but then I get a mismatch of colours with the status bar / navigation bar...

For an Interface Builder noob, how do I create a launch screen file that replicates that of the Settings app?

Gavin Hope
  • 2,173
  • 24
  • 38

1 Answers1

19

If you are using a storyboard file, you could set your view as the root view in a Navigation Controller Scene. A Navigation Controller's navigation bar automatically positions itself below the status bar.

Example

Don't forget to set the Navigation Controller as the initial view controller (by checking Is Initial View Controller in the property pane)

A Navigation Controller Scene automatically adds a table view controller as it's nested controller when you add it to the storyboard.

If you want to replace it with another controller, you'll have to remove the table view controller from the storyboard, add the controller you want to use to the storyboard and then hook it up (by command+dragging from the navigation controller to the view controller and then selecting the rootViewController outlet)

NOTE Objects (viewcontrollers etc.) in a launch screen storyboard should not have have any IBOutlets set. This will lead to errors.

Leon Lucardie
  • 9,541
  • 4
  • 50
  • 70
  • 1
    thanks, that worked exactly as I needed. A couple of questions: (1) is there any difference (performance?) between using a storyboard vs. a single view for the launch image? (2) I assume all of the constraints are set up correctly? (It tests fine). As I was saying, IB is new to me, and using the storyboard approach things look different again ;) (3) Given that I want a navigation bar in the launch image, is this a 'better', more correct approach than using a single view? From my limited experience it seems adding nav bar manually was a 'fiddly' approach? Cheers. – Gavin Hope Oct 22 '14 at 05:59
  • 1
    (1) There shouldn't be a user-noticable performance difference between storyboards and single views. (3) The problem with using a single view file is that it is harder to set up controllers for your views (which handle sizing etc.) in the file itself. In a storyboard setting up controllers is easier which allows you to delegate auto-sizing etc. with just a single interface definition file, which is conventient for launch screens. – Leon Lucardie Jan 12 '15 at 09:34
  • @LeonLucardie: Great idea to use a storyboard instead of a .xib file! However, if there are any IBOutlets on the view controller you will get a black launch image. See [this answer](http://stackoverflow.com/a/29420001/35690) for more details. – Senseful Apr 02 '15 at 18:33
  • 2
    I got "launch screens may not have connections" error. Anyone got workaround for this? – sarunw Jun 11 '15 at 05:03
  • this does not answer the question… – kubbing Dec 07 '15 at 16:42
  • 1
    @sarunw A launch screen storyboard cannot have an actual ViewController implementation in code. It should be just the storyboard file without the viewcontroller class or IBOutlets set. – Leon Lucardie Dec 08 '15 at 08:55
  • @kubbing In what way does it not answer the question? – Leon Lucardie Dec 08 '15 at 08:55
  • Excellent! Thank you! – Isaak Osipovich Dunayevsky Nov 02 '17 at 11:29