For iOS LaunchImage, do I need all images? - ios

If using launch image asset do I need to specify all the images if my app is only in portrait mode and only for iPhone? I.e. do I need the landscape images or the iPad images or will it work without them?

If your app is only in portrait mode and only for iPhone, then no you don't.
I would suggest using Storyboards instead of launch images. Here is how you could do so:
This is how:
Create a blank storyboard file named for example MyLaunchScreen.storyboard.
Click on your project and go to your Target Settings and, on the General tab, select the storyboard as your Launch Screen File. Xcode will then add a corresponding UILaunchStoryboardName key to your app’s Info.plist. When this key is present, Xcode will prioritize it over any launch images you might have set.
Add a view controller scene to the storyboard, add UIImageViews or whatever you like. Adding some constraints will make this storyboard work on all devices without having to set images for all devices.
If you still do want to use images, here is how:
a. Click on the project target, in the General tab, set the Launch images source to be an image asset
b. In the launchImage image set, toggle the attributes inspector and set the device classes that you'd like to add launch images for. In your case just the iPhone portrait checkbox should be selected:

You can specify which images you'll add, it should reflect the project settings device support. So no, you don't all the images. And be careful with the retina and retina HD support, your layout could be down-scaled.

Related

Xcode: use LaunchImagesSource instead of LaunchScreenFile

I was previously using a single Launch Screen File, but I would now like to switch to the Launch Images Source, where I can defined the launch screen files for all devices.
I have defined the LaunchImage set, and I have left Launch Screen File blank.
However when I run the app on my iPad Mini 3, I still don't get the image I defined for the iPads.
Should I set some other values?
Confirm in your project's Info.plist that there isn't an entry for
Launch screen interface file base name
UILaunchStoryboardName
In some cases, changing from a launch screen file to xcassets fails to remove this value.
I have the same values for the App Icons and Launch Images section.
Then, the way I have setup the LaunchImage on the sidebar has both iPad portrait and landscape selected:
And have added the 4 necessary files to comply with that configuration:

Lock LaunchScreen.xib orientation on iPhone 6 Plus

I am using a LaunchScreen.xib to start my app. This xib must works in portrait mode (only!). Anyone knows how can I achieve that with an iPhone 6/6s Plus (they can start the app in landscape)?
I believe if you open the Attributes Inspector for the assets catalog then you need check the landscape box like image
Hope my solution help you to resolved your issue.
From the Documentation:
Launch Images
Launch images for iPhone apps are always sized to match the dimensions
of the screen in portrait orientation. For applications that launch
into landscape orientation, you should use your preferred graphics
editing software to rotate the content of the launch image while
keeping the image's size consistent with a portrait launch image
(height > width).
Avoid using asset catalogs to manage the launch images of landscape
applications. Except for launch images used by the iPhone 6 Plus,
asset catalogs assume that all iPhone launch images are for the
portrait orientation. When your application is compiled, entries for
each launch image are added to the compiled information property list
under the UILaunchImages key. The value for the
UILaunchImageOrientation key in each of these entries is always
Portrait. These entries are then ignored at launch time because the
value of Portrait for the UILaunchImageOrientation key does not match
the launch orientation (Landscape Left or Landscape Right). The result
is a blank screen during launch as the system cannot find an
appropriate launch image.
Instead, you should use a Launch File if your application only
supports iOS 8 and above. Otherwise, you will need to add your launch
images as resources to your project and then add the UILaunchImages
key to your application's information property list. Be sure to
disable use of the asset catalog for managing the launch images by
selecting 'Don't use asset catalogs' from the Launch Image Source menu
under the General tab of the project editor for your applications'
target.
For more info:
If you are not using assets, use UILaunchImages key to make changes to the launchscreenimage in your application's information property list and then edit the value under each UILaunchImageName key to match the corresponding image from your project. Do not include the extension or any modifiers (#2x, #3x). You can edit your information property list by control+clicking on it in the File Navigator and choosing Open As > Source Code from the popup menu.

Launch screen custom image for iPad

I need to present different image on the launch screen for iPad.
Our designer provided only 2 images:
one for iPhone portrait
one for iPad landscape
So I cannot use Launch images and assets catalog
Instead of that I'm trying to use LaunchScreen.xib,
I'm trying to name them like it is described here https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/LoadingResources/Introduction/Introduction.html
with ~ipad and ~iphone postfixes
But I didn't manage to figure out how I should place them in the assets catalog
How can I present different images for iPad and iPhone
I found out that it could be done with right click on the detail asset view in xCode
Try to open assets catalog in xcode and choose LaunchImage.
Next right click and select New Launch Image.
After that you will have new asset. image here.
Put you images there.
Next step is delete old LaunchImage asset and rename new.

Splash screen not visible for iPad, only a black screen gets shown

I have an universal app. The splash screen loads fine for iPhone but the same is not visible on the iPad. Instead a black screen appears in its place. I have gone through the questions posted in this regard and have followed the steps but to no avail. I am using asset catalog in my project. Storyboards have not been used. The names and dimensions of the images used are as follows:
1. Default-Landscape.png (1024x768)
2. Default-Landscape#2x.png (2048x1536)
3. Default-Portrait.png (768x1024)
4. Default-Portrait#2x.png (1536x2048)
5. Default-568h.png (640x1136)
6. Default.png (320x480)
7. Default#2x.png (640x960)
Please let me know if there is anything wrong with the dimensions I am using. The options I have selected for the Attributes Inspector for the Launch image are given in the image below:
Following is the setting for Launch image:
I added the same launch images to a sample app and the launch screen showed up perfectly on iPad.
EDIT:
As per the suggestion of #iphonemaclover, the problem was solved using "You should also remove any other key suffixed with (iPad) or ~ipad." There was a key UILaunchImages~ipad in the plist which I removed. Now the launch screen is properly visible.
Please delete your derived data and clean the your project.
Also reset your simmulater if you running over it.
Hope it will help.
Also check you have selected Universal App in your target setting.
EDIT
You should probably be using an Asset Catalogue for your launch images, which might be what Xcode is expecting. You can see what Xcode is expecting in the General tab for your target:
MORE Suggestion
Q: Why does my app launch to a black screen on iPad?
A: Apps that have been designed only for iPhone may launch to a blank screen when run on an iPad. This is caused by the presence of an empty iPad specific storyboard in the app bundle as well as an iPad specific UIMainStoryboardFile key in the app's Information Property List (Info.plist) file. Both are automatically created by the various Xcode template projects if the Universal option is selected.
...
In Xcode
Look for a file named MainStoryboard_iPad.storyboard in the file navigator. If this file is present, remove it from your project.
In In your app's Information Property List
Look for a key named Main storyboard file base name (iPad) or UIMainStoryboardFile~ipad. If this key is present, remove it. You should also remove any other key suffixed with (iPad) or ~ipad.
Finally, test your app on an iPad or in the iPad simulator and verify that it behaves as expected.
You should add your launch image to your asset catalogue, and make sure the setting shown is configured correctly.
If you don't have one already, you can add an asset catalogue by going to File > New > File, the look under the Resource tab.
Probably not related to most people's problems but I would like to add another possible issue. I had the same problem with my project. I could see my iPad images in X-Code but what I missed was that the title underneath was "unassigned" and not "iPad Portrait" (this was probably because it was a boilerplate React Native project that was initially configured only for iPhone).
After making my app universal, I needed to recreate my LaunchImage set which then had designated placeholders for iPad. I re-added all my images, assigned the new Launch Image set, clean, build and it was fixed. Hopefully it saves someone else some time.
If you're not loading an image in your slash screen do you get the white view? If you're not getting, then your view is not loaded. That is why you're getting a black screen.

LaunchScreen.xib single image for all devices?

I'm using the current Xcode and targeting iOS 8.
I'm wondering if it's okay if in my LaunchScreen.xib I put a single imageView that is constrained to all sides of the parent container. Within that image view will be my splash image called: splash.png;
Now here's the kicker, this splash.png will be hi-res and all devices (iPhone/iPad) will use this one image. Is this ok according to apple's guidelines? (note: it's okay with me) I don't mind if it stretches to fit). Also note my app's only in portrait.
Yes. It's fine, that's because they introduced this new feature (launchscreen.xib).
For deployment targets prior to iOS 8, you add a set of launch images to an asset
catalog for each of the possible screen sizes.
New projects are created with a launch screen file called
LaunchScreen.xib. Alternately, you can create a new launch screen file
using File > New, selecting the User Interface category, and choosing
a file type of Launch Screen. The launch screen uses size classes to
adapt to different screen sizes and orientations, see Adapt to Multiple iOS Screen Sizes and Orientations with Size Classes for more
information.
Reference : Create and Set the iOS Launch Images or Launch Screen File

Resources