SoFunction
Updated on 2025-04-11

IOS development code sharing: string to get the splash screen picture

IOS development code sharing: string to get the splash screen picture

Updated: September 18, 2014 09:20:42 Submission: hebedich
This article is the first article in the IOS development code sharing series. Here is a string code for obtaining the startup screen picture. This code supports iPhone 6 and below. It supports iPhone and iPad, which is very practical. I hope it will be helpful to everyone.

This code supports iPhone 6 or below. Supports iPhone and iPad

+(NSString*)getLaunchImageName
{
     
    NSArray* images= @[@"", @"LaunchImage@",@"LaunchImage-700@",@"LaunchImage-568h@",@"LaunchImage-700-568h@",@"LaunchImage-700-Portrait@2x~",@"LaunchImage-Portrait@2x~",@"LaunchImage-700-Portrait~",@"LaunchImage-Portrait~",@"LaunchImage-Landscape@2x~",@"LaunchImage-700-Landscape@2x~",@"LaunchImage-Landscape~",@"LaunchImage-700-Landscape~"];
     
    UIImage *splashImage;
     
    if ([self isDeviceiPhone])
    {
        if ([self isDeviceiPhone4] && [self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (!=0)
                return images[1];
            else
                return images[2];
        }
        else if ([self isDeviceiPhone5])
        {
            splashImage = [UIImage imageNamed:images[1]];
            if (!=0)
                return images[3];
            else
                return images[4];
        }
        else
            return images[0]; //Non-retina iPhone
    }
    else if ([[UIDevice currentDevice] orientation]==UIDeviceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIDeviceOrientationPortraitUpsideDown)//iPad Portrait
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[5]];
            if (!=0)
                return images[5];
            else
                return images[6];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[7]];
            if (!=0)
                return images[7];
            else
                return images[8];
        }
         
    }
    else
    {
        if ([self isDeviceRetina])
        {
            splashImage = [UIImage imageNamed:images[9]];
            if (!=0)
                return images[9];
            else
                return images[10];
        }
        else
        {
            splashImage = [UIImage imageNamed:images[11]];
            if (!=0)
                return images[11];
            else
                return images[12];
        }
    }
}
 
+(BOOL)isDeviceiPhone
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
    {
        return TRUE;
    }
     
    return FALSE;
}
 
+(BOOL)isDeviceiPhone4
{
    if ([[UIScreen mainScreen] bounds].==480)
        return TRUE;
     
    return FALSE;
}
 
 
+(BOOL)isDeviceRetina
{
    if ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)] &&
        ([UIScreen mainScreen].scale == 2.0))        // Retina display
    {
        return TRUE;
    }
    else                                          // non-Retina display
    {
        return FALSE;
    }
}
 
 
+(BOOL)isDeviceiPhone5
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone && [[UIScreen mainScreen] bounds].>480)
    {
        return TRUE;
    }
    return FALSE;
}

  • IOS Development
  • Code Sharing
  • Get
  • Sponsor screen
  • picture

Related Articles

  • Comprehensive analysis of synchronous requests, asynchronous requests, GET requests, and POST requests in iOS

    Through this article, we have comprehensively analyzed synchronous requests, asynchronous requests, GET requests, and POST requests in iOS. It is very good and has reference value. Interested friends can learn together.
    2016-08-08
  • Detailed explanation of the principle of global variable assignment crash under multithreaded iOS development

    This article mainly introduces the detailed explanation of the principle of global variable assignment crash under multi-threaded iOS development. Friends in need can refer to it for reference. I hope it can be helpful. I wish you more progress and get promoted as soon as possible to get a salary increase as soon as possible.
    2022-07-07
  • iOS implements two-way data transfer between two controllers

    This article mainly introduces the relevant information on iOS to implement two-way data transmission between two controllers. Interested friends can refer to it.
    2016-05-05
  • Example of how to display gif diagrams in iOS

    This article mainly introduces relevant information about the description of gif diagrams in iOS. The article introduces the example code in detail, which has certain reference learning value for iOS developers. Friends who need it, let’s learn together.
    2019-06-06
  • Problems and adaptation methods encountered in the project after iOS 11 update and iPhone X launch

    This article mainly introduces the problems and adaptations encountered in the project after the iOS 11 update and the iPhone X launch. Friends who need it can refer to it
    2017-10-10
  • Ideas for localization of ios multiple languages

    IOS program implements localization methods for multiple languages. Recently, it is going to multi-language localization for a game. I have found some solutions online, and I have compiled a set of solutions with my own little ideas to share with you!
    2015-05-05
  • IOS LaunchScreen setting startup pictures and startup page residence time details

    This article mainly introduces the detailed explanation of the startup image and the start page residence time of IOS LaunchScreen. Friends who need it can refer to it.
    2017-02-02
  • How to call WebService (SOAP interface) with IOS

    This article mainly introduces how to use IOS to call WebService (SOAP interface). Friends who need it can refer to it.
    2015-07-07
  • Simple implementation code for iOS emoji keyboard

    This article mainly introduces the simple implementation code of iOS emoticon keyboard in detail, which has certain reference value. Interested friends can refer to it.
    2017-03-03
  • Native usage of sqlite database in iOS

    This article mainly introduces the native usage of sqlite database in iOS in detail. I believe you have heard of sqlite database. It is a very light database. The database only has one file and can be used as soon as possible. Interested friends can refer to 3
    2016-05-05

Latest Comments