Can I choose my launch image programmatically?

北战南征 提交于 2020-01-15 02:47:07

问题


My app gives the shuttle schedule for my school's shuttle bus, and I am updating the app to check what day of the year it is, and if it is summer to display the summer schedule, which is different from the normal schedule. That part's easy.

What I'm wondering is if I can choose to use a different launch image based on a programmatic condition, such as:

if ( today isBetweenDate: juneFirst andDate: augustThirtyFirst ) {
     launchImage == summerLaunchImage.png 
}

回答1:


The initial launch screen displayed cannot be changed programmatically : you need to provide a single image an tell the app it's the launch screen. You can't change that programmatically.

What you can do is show your own splashscreen after the launch screen when you app gain the focus in didFinishLaunchingWithOptions of your UIApplicationDelegate




回答2:


As others have said implement your own launcher screen. The easiest way to do is is to put an NSTimer that will move it automatically to your next screen after X number of seconds.

Here's some sample code.

In *.h

@interface v2ViewController : UIViewController
{
    NSTimer *timer1;
    NSTimer *timer2;

    IBOutlet UIImageView *backgroundImgVw;

}

In *.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

//set your backgroundImgVw / Launch Image here

//then move on
    timer2 = [NSTimer scheduledTimerWithTimeInterval:2.5 target:self selector:@selector(moveOn) userInfo:nil repeats:NO];

}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (IBAction) moveOn
{
    //Now go to the Display Call Page
    [self performSegueWithIdentifier:@"MoveOn" sender:nil];
}


来源:https://stackoverflow.com/questions/23637378/can-i-choose-my-launch-image-programmatically

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!