问题
My app doesn't use auto layout, it was originally designed for an iPhone 4/4s and the UI has been mostly untouched since then. The layout is fairly minimal, so it hasnt been deemed a priority to switch it autolayout.
Previously building for iOS8 my app would scale properly on iPhone 5, and newer, filling the screen. The View itself would fill the entire screen, while the icons would scale proportionally (such that they were not distorted). however it seems now that using the iOS9 beta the app receives black bars at both top and bottom, and its basically displayed as a scaled iPhone 4 app, resulting in black bars on the top and bottom.
Basically I want to it simply scale to fit the full screen, the same as it did in iOS8. Can anyone shine some light onto what has changed which has caused these black bars?
I should add, if it build using xcode 7 (ios9 xcode) and deploy a device with iOs8 it works fine, the issue is deploying to iOS9 devices.
The app looks like this on iOS9 now, the red area is the apps usable space now, whereas previously it was the entire size (note black bars).
回答1:
@Fantina @Goles I was able to temporarily fix this by creating and adding a Default-568h@2x.png
file with resolution 640x1136. I then updated the 'App Icons and Launch Images' Section to look like this:
I don't think this is a long term solution because in order to be compliant with iOS9 and split-screen apps, Apple is requiring storyboard or xib files. This makes it difficult for developers who rely solely on programatic view generation/layout. URGH.
回答2:
I had exactly the same issue, and this is weird, I've solved the error and I don't really know why my solution do the trick.
Add a Launch Screen File
to your project (I've copied one from another newer project I have), and that's all, the app now uses all the screen again.
To add a Launch Screen File
first create a xib file, use a UIView and fill with whatever you want.
Then you have to select the project in the left side of the screen, select the app target (not the project one), on the general tab search for App Icons and Launch Images
and put the xib name you just created on Launch Screen File
.
The problem with this, is that this activates the Size classes
in the app interface, so you have to review your app's interface because scaling is no longer working.
PS: I'm using Xcode 7.0 GM
回答3:
I had a similar problem and I've solved it by setting up Main.storyboard as Launch Screen File in App Configuration Screen. It made all screens fit the entire screen.
回答4:
You can add a LaunchScreen storyboard by : File/New/File..., and then in the iOS group, select UserInterface/Launch Screen.
Then select it as the Launch Screen for your app, as explained in the answer given by Fantini. That's with Xcode 7.0
回答5:
I ran into this after upgrading to xcode 9. Interestingly the app looked fine when running on simulators but showed a black bar at the bottom when running on a connected device. In the menu choosing product and then holding Option -> clean build folder fixed the issue for me.
来源:https://stackoverflow.com/questions/32312906/ios9-app-has-black-bars-on-top-and-bottom