1

I have a problem with my code. My application displays within iOS safe area layout guide, however I'd like to force it to display "outside". I have searched the internet and unfortunately I found only "reverse" problems. I don't use interface builder, all my views I create programmatically. I have a main view controller which starts up automatically with the app and from here I start creating all my stuff. My interface builder just shows this view controller and a view assigned to it. Interestingly, the view appears to be really full screen when viewed in IB.

Yes, I tried turning on/off the "Use Safe Area Layout Guide" option for the view. Also I tried to use topLayoutGuide and bottomLayout guide instead and constrain the main view to them, but it still fails:

- (void)viewDidLoad {
     [super viewDidLoad];
     UILayoutGuide *margins = self.view.safeAreaLayoutGuide;
     [NSLayoutConstraint activateConstraints:@[[self.view.topAnchor constraintEqualToAnchor:self.topLayoutGuide.topAnchor],
                                          [self.view.bottomAnchor constraintEqualToAnchor:self.bottomLayoutGuide.bottomAnchor]
                                          ]];

     //...
}

This is what I see in the IB:

1) view

enter image description here

2) safe area - I can't get rid of it in any way:

enter image description here

3) result (simulator / real device):

enter image description here

I also did RTFM but a) I'm stupid, b) I'm too tired, c) both

Any help would be appreciated :)

user1880342
  • 128
  • 10
  • Do you use constraints ? – Julius Feb 24 '19 at 23:44
  • Basically I use auto layout everywhere, but I don't have any code that sets any constraints to this view, so I believe this is getting arranged by iOS itself somehow. – user1880342 Feb 24 '19 at 23:49
  • Ok, I think I found the issue. I created a new project and everything works there well. I started examining the differences in project settings, etc. and found out that the new one does not use Launchimage, but my app uses. So I tried deleting the launchimage from my app and it started working. From there I started checking what's going on and finally I found that my app is missing Launchimage assets for iPhone X. I added one with designated size and now it works fine, no additional changes required. It seems that iOS automatically fallsback to smaller screen if there is no proper launchimage. – user1880342 Feb 25 '19 at 00:44

2 Answers2

0

If you use constraints on the view, it will usually automatically align to the safe area. You can override this and have it constrain to the superview instead by clicking the little arrow to the right for a drop down menu:

enter image description here

You then select "View" instead of "Safe Area". Also make sure to un-click "Constrain to margins" or it still won't fill out the whole screen.

Marshall D
  • 454
  • 3
  • 20
  • 1
    But in the screen shot, Safe Area is what's checked. Plus, you didn't tell him to uncheck "Constrain to margins" (and in fact in your screen shot it is still checked), so that isn't going to solve his problem. – matt Feb 25 '19 at 01:02
  • @matt yes just realized this. fixing it now. – Marshall D Feb 25 '19 at 01:04
  • Thanks guys, but as I mentioned in the comment, I found the issue - it was caused by missing LaunchImage asset for iPhone XR. Now I felt into another issue, I added the image with proper size to assets where all my launch images are and the app displays in full screen. The problem is that the launch image is not displayed - instead I can see some default launch image with three white dots. I have recreated assets and still the same issue... – user1880342 Feb 25 '19 at 01:45
  • @matt you probably have a better shot at handling this new question than me ^ – Marshall D Feb 25 '19 at 01:47
0

I resolved my issue. The application was not displaying in full screen because of missing launch image in my assets for iPhone XR. Because of this iOS was falling back to the closest launch image keeping aspect ratio, thus defining the application size.

The second issue (not loading the image, displaying some default splash screen insead) - removing the app from device and installing from scratch helped.

Thanks everyone involved :)

user1880342
  • 128
  • 10