Instead of doing this

    if(isPhone5 || isPad) {
        navigationBarHeightPortrait = 64;
    }

You should be doing this

[self.previewMainView.topAnchor constraintEqualToAnchor:self.topLayoutGuide.bottomAnchor constant:0.0].active = YES;
}

This pins the view to the top of the maximum viewable area taking into account the navigation bar, the status bar, and anything else that would block your views content.

Links that help
https://developer.apple.com/documentation/uikit/uiviewcontroller/1621367-toplayoutguide
https://useyourloaf.com/blog/pain-free-constraints-with-layout-anchors/

Advertisements