Access iPad launch images programmatically?
I'm using LaunchImage.launchimage
in Images.xcassets
to manage the launch images. But I'm trying to use the launch images inside the app also.
I've read this answer :
The documentation indicates that the imageNamed: method on UIImage
should auto-magically select the correct version
So, I used this code
UIImageView *backImage = [UIImageView new];
backImage.image = [UIImage imageNamed:@"LaunchImage"];
When working on iPhone 4,5,6,6+ it works perfectly fine and get the correct LaunchImage, but when working on iPad retina it returns LaunchImage-700@2x.png
which is the LaunchImage of iPhone 4s 640 x 960 pixels
So how can I access the correct LaunchImage of iPad programatically ??
The contents of Contents.json
in LaunchImage
folder
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "LaunchImage-800-Portrait-736h@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "LaunchImage-800-667h@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-700-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700-568h@2x.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
ios objective-c ipad cocoa-touch launchimage
add a comment |
I'm using LaunchImage.launchimage
in Images.xcassets
to manage the launch images. But I'm trying to use the launch images inside the app also.
I've read this answer :
The documentation indicates that the imageNamed: method on UIImage
should auto-magically select the correct version
So, I used this code
UIImageView *backImage = [UIImageView new];
backImage.image = [UIImage imageNamed:@"LaunchImage"];
When working on iPhone 4,5,6,6+ it works perfectly fine and get the correct LaunchImage, but when working on iPad retina it returns LaunchImage-700@2x.png
which is the LaunchImage of iPhone 4s 640 x 960 pixels
So how can I access the correct LaunchImage of iPad programatically ??
The contents of Contents.json
in LaunchImage
folder
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "LaunchImage-800-Portrait-736h@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "LaunchImage-800-667h@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-700-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700-568h@2x.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
ios objective-c ipad cocoa-touch launchimage
add a comment |
I'm using LaunchImage.launchimage
in Images.xcassets
to manage the launch images. But I'm trying to use the launch images inside the app also.
I've read this answer :
The documentation indicates that the imageNamed: method on UIImage
should auto-magically select the correct version
So, I used this code
UIImageView *backImage = [UIImageView new];
backImage.image = [UIImage imageNamed:@"LaunchImage"];
When working on iPhone 4,5,6,6+ it works perfectly fine and get the correct LaunchImage, but when working on iPad retina it returns LaunchImage-700@2x.png
which is the LaunchImage of iPhone 4s 640 x 960 pixels
So how can I access the correct LaunchImage of iPad programatically ??
The contents of Contents.json
in LaunchImage
folder
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "LaunchImage-800-Portrait-736h@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "LaunchImage-800-667h@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-700-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700-568h@2x.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
ios objective-c ipad cocoa-touch launchimage
I'm using LaunchImage.launchimage
in Images.xcassets
to manage the launch images. But I'm trying to use the launch images inside the app also.
I've read this answer :
The documentation indicates that the imageNamed: method on UIImage
should auto-magically select the correct version
So, I used this code
UIImageView *backImage = [UIImageView new];
backImage.image = [UIImage imageNamed:@"LaunchImage"];
When working on iPhone 4,5,6,6+ it works perfectly fine and get the correct LaunchImage, but when working on iPad retina it returns LaunchImage-700@2x.png
which is the LaunchImage of iPhone 4s 640 x 960 pixels
So how can I access the correct LaunchImage of iPad programatically ??
The contents of Contents.json
in LaunchImage
folder
{
"images" : [
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "736h",
"filename" : "LaunchImage-800-Portrait-736h@3x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "3x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "667h",
"filename" : "LaunchImage-800-667h@2x.png",
"minimum-system-version" : "8.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"extent" : "full-screen",
"idiom" : "iphone",
"subtype" : "retina4",
"filename" : "LaunchImage-700-568h@2x.png",
"minimum-system-version" : "7.0",
"orientation" : "portrait",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700@2x.png",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"extent" : "full-screen",
"filename" : "LaunchImage-700-568h@2x.png",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait~ipad.png",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape~ipad.png",
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Portrait@2x~ipad.png",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage-700-Landscape@2x~ipad.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
ios objective-c ipad cocoa-touch launchimage
ios objective-c ipad cocoa-touch launchimage
edited Jan 3 at 5:52
Cœur
19k9114155
19k9114155
asked Aug 9 '15 at 6:50
MujtabaFRMujtabaFR
2,33431743
2,33431743
add a comment |
add a comment |
3 Answers
3
active
oldest
votes
I've solved this issue using a long method
BOOL deviceIsIpad = NO;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
deviceIsIpad = YES;
}
if (!deviceIsIpad) {
backImage.image = [UIImage imageNamed:@"LaunchImage"];
} else {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
CGFloat screenScale = [[UIScreen mainScreen] scale];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad.png"];
}
} else {
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
}
}
}
add a comment |
I believe that those extensions (-700-Landscape@2x~ipad for example) are not recognisable.
Add the following item to your Contents.json just for testing purpose:
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage.png",
"scale" : "1x"
}
Now try the imageNamed: method.
Or try the imageNamed: with the image full name:
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage.png
and editing theContents.json
, nothing changed and still returning iPhone 4s image
– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well
– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
add a comment |
LaunchImage.launchimage
Are you really using Images.xcassets
to manage the launch images?
Aren't you using LaunchImage.launchimage
instead?
If so, there comes the confusion. You cannot load using [UIImage imageNamed:@"LaunchImage"];
from LaunchImage.launchimage
.
Canonical names
LaunchImage.png
LaunchImage@2x.png
LaunchImage-700@2x.png
LaunchImage-568h@2x.png
LaunchImage-700-568h@2x.png
LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-
Portrait@2x~ipad.png
is not in that list.
Yes, I'm usingLaunchImage.launchimage
which is insideImages.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
Even after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image
– MujtabaFR
Aug 9 '15 at 13:21
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31901678%2faccess-ipad-launch-images-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I've solved this issue using a long method
BOOL deviceIsIpad = NO;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
deviceIsIpad = YES;
}
if (!deviceIsIpad) {
backImage.image = [UIImage imageNamed:@"LaunchImage"];
} else {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
CGFloat screenScale = [[UIScreen mainScreen] scale];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad.png"];
}
} else {
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
}
}
}
add a comment |
I've solved this issue using a long method
BOOL deviceIsIpad = NO;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
deviceIsIpad = YES;
}
if (!deviceIsIpad) {
backImage.image = [UIImage imageNamed:@"LaunchImage"];
} else {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
CGFloat screenScale = [[UIScreen mainScreen] scale];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad.png"];
}
} else {
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
}
}
}
add a comment |
I've solved this issue using a long method
BOOL deviceIsIpad = NO;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
deviceIsIpad = YES;
}
if (!deviceIsIpad) {
backImage.image = [UIImage imageNamed:@"LaunchImage"];
} else {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
CGFloat screenScale = [[UIScreen mainScreen] scale];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad.png"];
}
} else {
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
}
}
}
I've solved this issue using a long method
BOOL deviceIsIpad = NO;
if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
deviceIsIpad = YES;
}
if (!deviceIsIpad) {
backImage.image = [UIImage imageNamed:@"LaunchImage"];
} else {
UIInterfaceOrientation interfaceOrientation = self.interfaceOrientation;
CGFloat screenScale = [[UIScreen mainScreen] scale];
if (interfaceOrientation == UIDeviceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown){
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Portrait~ipad.png"];
}
} else {
if (screenScale > 1) {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape@2x~ipad.png"];
} else {
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
}
}
}
answered Aug 12 '15 at 18:59
MujtabaFRMujtabaFR
2,33431743
2,33431743
add a comment |
add a comment |
I believe that those extensions (-700-Landscape@2x~ipad for example) are not recognisable.
Add the following item to your Contents.json just for testing purpose:
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage.png",
"scale" : "1x"
}
Now try the imageNamed: method.
Or try the imageNamed: with the image full name:
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage.png
and editing theContents.json
, nothing changed and still returning iPhone 4s image
– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well
– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
add a comment |
I believe that those extensions (-700-Landscape@2x~ipad for example) are not recognisable.
Add the following item to your Contents.json just for testing purpose:
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage.png",
"scale" : "1x"
}
Now try the imageNamed: method.
Or try the imageNamed: with the image full name:
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage.png
and editing theContents.json
, nothing changed and still returning iPhone 4s image
– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well
– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
add a comment |
I believe that those extensions (-700-Landscape@2x~ipad for example) are not recognisable.
Add the following item to your Contents.json just for testing purpose:
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage.png",
"scale" : "1x"
}
Now try the imageNamed: method.
Or try the imageNamed: with the image full name:
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
I believe that those extensions (-700-Landscape@2x~ipad for example) are not recognisable.
Add the following item to your Contents.json just for testing purpose:
{
"orientation" : "landscape",
"idiom" : "ipad",
"extent" : "full-screen",
"filename" : "LaunchImage.png",
"scale" : "1x"
}
Now try the imageNamed: method.
Or try the imageNamed: with the image full name:
backImage.image = [UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"];
answered Aug 9 '15 at 8:56
hasanhasan
17.6k74981
17.6k74981
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage.png
and editing theContents.json
, nothing changed and still returning iPhone 4s image
– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well
– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
add a comment |
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage.png
and editing theContents.json
, nothing changed and still returning iPhone 4s image
– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well
– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
if this didn't your too. you need to get the Images.xcassets bundle. please confirm. I will add the code that gets Images.xcassets bundle.
– hasan
Aug 9 '15 at 8:57
Sorry.. event after renaming
LaunchImage-700-Portrait~ipad.png
to LaunchImage.png
and editing the Contents.json
, nothing changed and still returning iPhone 4s image– MujtabaFR
Aug 9 '15 at 13:16
Sorry.. event after renaming
LaunchImage-700-Portrait~ipad.png
to LaunchImage.png
and editing the Contents.json
, nothing changed and still returning iPhone 4s image– MujtabaFR
Aug 9 '15 at 13:16
But when using full image name like this
[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well– MujtabaFR
Aug 9 '15 at 13:18
But when using full image name like this
[UIImage imageNamed:@"LaunchImage-700-Landscape~ipad.png"]
it works.. but that will need much more codes to work well– MujtabaFR
Aug 9 '15 at 13:18
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
I know. Thats never worked for me too. I believe that apple never rly supported this 100% for all these extensions. Only some works. The simple ones as @2x only
– hasan
Aug 9 '15 at 13:21
add a comment |
LaunchImage.launchimage
Are you really using Images.xcassets
to manage the launch images?
Aren't you using LaunchImage.launchimage
instead?
If so, there comes the confusion. You cannot load using [UIImage imageNamed:@"LaunchImage"];
from LaunchImage.launchimage
.
Canonical names
LaunchImage.png
LaunchImage@2x.png
LaunchImage-700@2x.png
LaunchImage-568h@2x.png
LaunchImage-700-568h@2x.png
LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-
Portrait@2x~ipad.png
is not in that list.
Yes, I'm usingLaunchImage.launchimage
which is insideImages.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
Even after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image
– MujtabaFR
Aug 9 '15 at 13:21
add a comment |
LaunchImage.launchimage
Are you really using Images.xcassets
to manage the launch images?
Aren't you using LaunchImage.launchimage
instead?
If so, there comes the confusion. You cannot load using [UIImage imageNamed:@"LaunchImage"];
from LaunchImage.launchimage
.
Canonical names
LaunchImage.png
LaunchImage@2x.png
LaunchImage-700@2x.png
LaunchImage-568h@2x.png
LaunchImage-700-568h@2x.png
LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-
Portrait@2x~ipad.png
is not in that list.
Yes, I'm usingLaunchImage.launchimage
which is insideImages.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
Even after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image
– MujtabaFR
Aug 9 '15 at 13:21
add a comment |
LaunchImage.launchimage
Are you really using Images.xcassets
to manage the launch images?
Aren't you using LaunchImage.launchimage
instead?
If so, there comes the confusion. You cannot load using [UIImage imageNamed:@"LaunchImage"];
from LaunchImage.launchimage
.
Canonical names
LaunchImage.png
LaunchImage@2x.png
LaunchImage-700@2x.png
LaunchImage-568h@2x.png
LaunchImage-700-568h@2x.png
LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-
Portrait@2x~ipad.png
is not in that list.
LaunchImage.launchimage
Are you really using Images.xcassets
to manage the launch images?
Aren't you using LaunchImage.launchimage
instead?
If so, there comes the confusion. You cannot load using [UIImage imageNamed:@"LaunchImage"];
from LaunchImage.launchimage
.
Canonical names
LaunchImage.png
LaunchImage@2x.png
LaunchImage-700@2x.png
LaunchImage-568h@2x.png
LaunchImage-700-568h@2x.png
LaunchImage-700-Landscape@2x~ipad.png
LaunchImage-700-
Portrait@2x~ipad.png
is not in that list.
answered Aug 9 '15 at 9:20
SwiftArchitectSwiftArchitect
32.8k15107136
32.8k15107136
Yes, I'm usingLaunchImage.launchimage
which is insideImages.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
Even after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image
– MujtabaFR
Aug 9 '15 at 13:21
add a comment |
Yes, I'm usingLaunchImage.launchimage
which is insideImages.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
Even after renamingLaunchImage-700-Portrait~ipad.png
toLaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image
– MujtabaFR
Aug 9 '15 at 13:21
Yes, I'm using
LaunchImage.launchimage
which is inside Images.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
Yes, I'm using
LaunchImage.launchimage
which is inside Images.xcassets
– MujtabaFR
Aug 9 '15 at 13:20
1
1
Even after renaming
LaunchImage-700-Portrait~ipad.png
to LaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image– MujtabaFR
Aug 9 '15 at 13:21
Even after renaming
LaunchImage-700-Portrait~ipad.png
to LaunchImage-700~ipad.png
and editing the Contents.json, nothing changed and still returning iPhone 4s launch image– MujtabaFR
Aug 9 '15 at 13:21
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31901678%2faccess-ipad-launch-images-programmatically%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown