iOS: Multiple launch images - ios

Is it possible to provide multiple launch images instead of just one Default.png launch image? My goal is, that you have for example 5 different launch images and for every application start it shows another one.
Just in case someone responds with that, I know that there is the possibility to have different launch images for different configurations (e.g. screen orientation). But that's not what I'm looking for. I'd like to have different launch images for exactly the same configuration, with the only variable different being the time of the launch.

Judging from this link, I don't believe it's possible. You have some latitude in configuring different launch images for Custom URL Schemes or even to localize them, but other than that, since they are specified in the .plist file so that iOS handles them quickly before your app is processing, that's as much latitude as you get...

There are rumors that it's possible to load default image from Document folder:
set path in info.plist ../Document/Default.png
on each app launch override that Default.png with one of your predefined images
*on first launch the start-up screen will be black
PS. I didn't try it, so can't say that it works. And even if it works you can meet problems with Apple review process.

Would be possible if you would insert your launch images using javascript/jquery vs. entering plain HTML.
In your script you would have to specify your logic for what splash screen should be used when. Then use this:
<script type="text/javascript">
(function() {
var a;
if(navigator.platform==="iPad"){
a = window.orientation === 90 || window.orientation === -90 ?
"landscape.jpg":"portrait.jpg"
} else {
a = window.devicePixelRatio === 2 ?
"retina.jpg" : "startup.jpg"
}
document.write('<link rel="apple-touch-startup-image" href="'+a+'"/>')
})()
</script>
Your logic would have to add some variable to the images name. So if it's time, you will have
landscape-Morning.jpg
landscape-Noon.jpg
landscape-TeaTime.jpg
landscape-Evening.jpg
Same for the other images.
Haven't tried this but since you can use javscript to set which image to be displayed depending on orientation it shouldn't be a problem to set which image depending on time of day.

Related

Get all elements in the view of iphone app using xcode

I am trying to take screenshot of every screen during iphone app automation on a simulator. Along with the screenshot I also want to extract all strings in the that particular view before taking a screenshot using xcode. Is there a way to do that? Purpose is to send these screenshots and strings for validation to another tool.
This can be done using Web Driver Agent(WDA) provided by facebook. It does provide all the functionalities you need for your app.
Here is link to github repo for it:
https://github.com/facebook/WebDriverAgent
Please have a look at it. It might help you achieving your goal.
If you are using the XCUITest framework for your automation, you can use XCUIScreen.main.screenshot() to get a screenshot of the current state.
To fetch all text currently on screen you can use XCUIApplication().descendants(matching: .textField) or .buttons or .any or whatever you expect to be on the screen, and extract the text from the element
let descendants = XCUIApplication().descendants(matching: .textField)
foreach descendant in descendants { descendant.label /*do something*/ }
You need to set an Accessibility Identifier on the view elements for this to work.

How To Load The Image Set(The Bundle) From Images.xcasset in iOS

When I am developing apps in iOS before, I always put the image sources of the app at the root directory of the project, and then I will load them using [UIImage imageNamed:#"image.png"]. I did't even include various sizes and resolutions such as image#2x or image#3x. But I am afraid this is not a good practice, because I cannot deal with different screen resolutions.
Now, I want to make use of the Images.xcasset to store all my image sources so that I will be able to load just the bundle name, and hoping that the system will pick the image with the right resolution automatically. Therefore, I made a test and place my image set under Images.xcasset and named it as images, and then in my UIViewController.m I am trying to load the image by calling [UIImage imageName:images]. As a result, it didn't work. So I searched for an answer and found out that I should call [UIImage imageName:#"images60x60#2x.png"] in order to load the the 60pt #2x image.
But I think this still did not solve my problem, because I am still choosing which image to load. Is there a way to load the entire image set or load the image according to the resolution of the screen?
Please help. Many Thanks.
EDIT: Added Screen Shots
I use AppIcon as a test
As you said at last that you are using AppIcon as a test. Please don't AppIcon it is made for internal use. try to create you own imageSet and use that. It should work.
Two things :
As said Ankit, do not use App Icon, use your own set
do not use a file suffix. Just reference [UIImage imageName:#"MyImage"] (not [UIImage imageName:#"MyImage.png"])

What name should i give for a ipad background image

Im creating a universal app. in my login page i am having a background image i named it as LoginBG#2x and LoginBG#3x for iphone-4,5 and iphone-6 respectively. So, what name should i give for the ipad version images so that iOS will automatically pick them up when my app is viewed in iPad
Use Image Asset Catalogs instead.
It manages image according to device.
You can drag and drop images in respective position -
For more information read - Asset Catalogs
You can give the name as :
file~ipad.png
file#2x~ipad.png
Or batter you can use the assets catalog
Yo can give name like easily you can remember.
like
abc.png
abc_ipad.png

iOS Duration of Splash Screen (Default.png)

im using a Default.png file for my iPad-app. It appears correctly but i could'nt find a way to modify the duration of the splash screen. Has somebody any suggestions? Google has many sites that show how to setup the startscreen but could'nt find a solution for my problem.
The first rule of Human Interface Guidelines for Splash Screens is: don't use splash screens. The second rule is: don't use splash screens!:
Supply a launch image to improve user experience.
Avoid using your launch image as an opportunity to provide:
An “application entry experience,” such as a splash screen
An About window
Branding elements, unless they are a static part of your application’s first screen
If you absolutely must include a long-duration splash screen, and have darn good reasons for doing so, the usual approach is to throw up a UIImageView containing a copy of you launch image in, e.g., application:didFinishLaunchingWithOptions: - which should provide the illusion of a lengthy splash screen.
But please don't.
Using a "splash screen" (Logo, etc) is not the idea of the Default.png!
Read the HIG from Apple.
The (splash) screen (named loading screen) is not for a Logo showing or something like this.
When having multitasking enabled, the "splash screen" shows up really rare.
The splash screen should, like the apple apps does, only show the interface coming up in the first application screen without any localized strings, etc.
Also keep in mind:
The faster the iOS Device get, the shorter you can see the Default.png. So avoid using it for any important CI/CD content.
The Default image is displayed while the app is loading and will be dismissed as soon as the app is ready. And there is no API to control that duration.
You can't technically modify the duration that the "Default" image stays there; it is designed to just be a temporary image "foreshadowing" the app actually starting up and isn't specifically designed as a splash screen.
I recommend that you keep the "splash screen effect" by adding an image view to the screen as the app starts in the -application:didFinishLaunchingWithOptions: method. You can then set a timer which calls a method to animate the splash off after the designated time you want it to be. It will be there for a little longer than you specify depending on how long it actually took the app to load up, but it will give the effect you're after.
You can set the image view's image to [UIImage imageNamed:#"Default"] and it will access that Default artwork for you.
You can't change the duration. If you want it be shown longer though, you can add the same image to a view that you show while you're loading your data!
There is a good blog post here on how to create a splash screen using a UIImageView with a timer:
http://nullpointr.wordpress.com/2012/02/19/iphone-dev-how-to-implement-a-splash-screen/
Useful for beginners, who are still learning the best way to do things in iOS.
As #Conrad Shultz answered, splash screen should be used only via the supplied LaunchScreen.storyboard file by Xcode.
However, in rare situations you do want to prolong the splash screen:
Download A LOT of files before the app starts since the app depends on them.
Other reason...
This is the way to do it:
Inside AppDelegate, under didFinishLaunchingWithOptions you should:
Create a VC that has the same splash image and the same constraints
Present it
Dismiss it after a given time
The code:
let splashVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "splash")
window?.makeKeyAndVisible()
if let root = window?.rootViewController
{
root.present(splashVC, animated: false, completion: nil)
let dispatchTime = DispatchTime.now() + 3
// didFinishLaunchingWithOptions will return and this block will be executed afterwards, hence, async..
DispatchQueue.main.asyncAfter(deadline: dispatchTime, execute: {
root.presentedViewController?.dismiss(animated: false, completion: nil)
})
}
}

Image being loaded before app main method is called

I have an ipad app where I am seeing an image displaying briefly before the app starts (image is part of bundle).
My guess is that this is some wrong wiring of a xib file, but even when I set a breakpoint at the beginning of the main method, the image still appears before this point is reached.
Resetting the simulator does not help, and the scenario occurs on a device too.
Mmmm is the image named Default.png ?
I just don't see an other explanation for this problem ^^
By the way, I just don't use Interface Builder to avoid this kind of strange problems ^^

Resources