Make Fullscreen imageview match positioning of launch image on iOS - ios

In order to do an initial check on a boolean on the first launch of my app, I want to have a splash screen that acts as the initial screen, then decide which screen to navigate to... I know Apple doesn't suggest splash screens, but this should only take a few milliseconds...
Anyways, I want this screen to have an ImageView that fills the entire screen, and the asset to be an exact replica of the Launch Image, so that the user doesn't know see a visible difference in the image positioning.
However, I am unable to get the exact positioning correct on a 4-inch device or larger...
I've tried both setting the mode in Storyboard and setting the image and it's contentMode programatically... but it always seems to have a slight positioning change.
I've also tried to set the Launch Screen File property in my General Target settings ( to be the first screen of the storyboard, which is the ViewController I am referring to), but that just shows a black launch image :(
Ultimately, if I was able to access the actual LaunchImage from my .xcassets, that would likely solve the problem... but, as per this post, that seems impossible.
Any ideas ?

iOS app projects come with a LaunchScreen.xib file now, so I would suggest putting the splash screen image there. Also, when I checked the Launch Screen File option in General Target Settings, it gave me an option for the LaunchScreen.xib file, so whatever file you put there probably has to be a xib or storyboard file, not an image. If you want to use only images, the Launch Images Source option above the Launch Screen File option looks like what you want.
If you want to keep implementing the splash screen dynaically, you should not have to change the contentMode. The code should be something like:
UIImageView* imageview = [[UIImageView alloc] initWithImage:[UIImage named:#"splashScreen.png"]];
[imageview setFrame:[[UIScreen mainScreen] bounds]];

Related

Abandon image cassetts for LaunchScreen.storyboard

So I have a fairly old app, last time worked on before iPhone X(s) was released. Always used Launch Images Source instead of Launch Screen File as seen below.
I am now having issues launching on iPhone X, as the screen size is assumed from the LaunchImage and there is NO launch image currently provided for iPhone X(s) in the "LaunchImage" file of .xcassets folder.
What is the most straightforward way to abandon using cassets in use of the new "Launch Screen File"? I have already tried creating this and using it, but had no luck getting an UIImageView to resize an image with said screen sizes on devices.
Im really looking for a straightforward guide for creating a LaunchImage.storyboard file that can adapt a launch screen image(full-sized image) to any device size.
What is the most straightforward way to abandon using cassets in use of the new "Launch Screen File"?
Change the Launch Images Source pop-up menu to "Don't use asset catalogs".
Make a LaunchScreen.storyboard if there isn't one, and point Launch Screen File at it. Make sure your launch image storyboard uses autolayout and is designated as a launch screen.
Now configure your storyboard's view controller using autolayout so that it lays out correctly on all devices.

Launch screen image not displaying correctly

Working with the iOS launch screen and it's a very painful experience.
Finally got it to appear, but no matter what I do it won't align properly. It's either stretched too far, or in a weird position off the screen.
What values for mode and stretching should I use to display this image viewer in my .xib?
If you're using the Launch Screen.xib or Launch Screen.storyboard, you need to set the correct AutoLayout constraint in your IB file.
If you're not, you need to set the Launch Images Source in your project general settings page.

How do you Implement Landscape Launch Screen for iPhones?

How do you implement landscape launch screens for iPhones? I've seen the "plist duplicate" posts and added the arrays they suggested to my plist, and added my launch images to my xcassets file which is set as my launch image so it shows as just a black screen. when removing assets catalogue, theres a bar of black on both the left and right side of the screen the whole time the app is running. Also, if its not done through cassettes, what do you name the images and where do they go? Thanks!
Are you asking about launch images or launch screens?
There's no such thing as a landscape launch image for iPhone. You provide a normal launch image in portrait, and if the app launches in landscape, that launch image is automatically turned on its side.
But in this day and age it would be best to forget about launch images and use a launch screen, a xib file or storyboard. It knows nothing of orientation and doesn't need to know anything: you just configure its appearance using autolayout to match whatever the circumstances turn out to be.

Making UIImageView full screen on .xib

I'm trying to implement a "Launch Screen" .xib so that my app will get "This app is optimized for the iPhone6 and iPhone6 Plus" denotation in the app store.
So I create a new Launch Screen .xib template, delete the included label, drop a UIImageView onto it, I push the pin button and I set all the "spacing to the nearest neighbor" constraints to 0, I set the UIImageView to aspect fit, and have it point to one of my asset catalogs.
When I run the app on my phone, I'm getting some very weird results as far as the positioning of the UIImageView and the size of the image in it (it definitely isn't filling out the screen with the image). Does anyone have anyone have any idea of what I'm doing wrong here?
You don't give any actual details of what you are doing, so one has to guess. There are, however, two things to keep in mind here:
Where the image is shown doesn't really have all that much to do with the position/size of the image view. It has something to do with it, but the most important thing is actually the Content Mode of the image view.
Image views under auto layout are tricky, because they are resized based on the image - unless your constraints completely determine the height and width of the image view in some other way. In all probability your constraints are not doing that.
So the problem I was having was I trying to link the LaunchScreen.xib to a LaunchImage asset catalog. This will not work, you have to link it to a normal image asset catalog and use the universal image grouping.

Random launch screen on iOS apps [duplicate]

I have a sponsor logo on the launch image. Is there a way to dynamically change the launch image to rotate sponsor logos?
Thanks
The default image for an iphone app must be a fixed image file in your bundle. You cannot change it dynamically.
However, you can have a dynamic image that appears when the app loads after the launch image. You can set that up with animations or simply to select a random image each time.
According to Apple's HIG, Human Interface Guide, the splash screen is supposed to be used only as a placeholder to give the user the illusion the app is open while it completes it's startup process.
Apple will allow some use of the startup screen, but know they can and do have the right to reject your app solely on how you use it.
Like the previous answer stated, you could do anything you want after the initial startup screen has passed. Play a video, run an animation, or display a second view with your sponsored images.
And finally, I don't recommend doing this, but if you are determined to work something into the startup screen, you could try this.
The splash screen is hardcoded or set to 1 filename. Before your app closes, you could dynamically replace the hardcoded filename with a new file from a webservice or local storage, replacing the existing splash screen image. I haven't tried this, but it is more than likely possible. Just beware that it may not pass muster with Apple's approval process. Good luck.
As i needed different images on iPhone & iPad Splash screens, i followed below steps:
1. Add two UIImageViews
2. Set Width & Height constants for both UIImageViews as per your requirements.
3. Now select the iPhone UIImageView and set its Height Constraints Regular Regular (RR) height constant as 0.
4. Do the same for for iPad UIImageView and set its Height Regular Regular (RR) height constant as actual required height and set 0 to the Constant.
5. When you test it on iPhone the iPad ImageView will disappear and vice-versa will happen on iPad.

Resources