I am currently developing a landscape app that I would like to have a launch image in. Since launch images do not work in landscape, I want to make my launch image a view, and after about 5 seconds after this view is shown when the app launches, the view will switch to the original first view of the app. How do I do this? I am using storyboards.
Asked
Active
Viewed 41 times
0
-
And what have you tried so far? – Rafał Sroka May 17 '14 at 22:14
-
I tried using asset catalogs for the launch image and also not using asset catalogs. Both did not work. Then I made a test app. When the only box checked off was portrait the launch image showed perfectly. However when I only checked off landscape left and right it did not work. – msweet168 May 17 '14 at 22:17
2 Answers
1
Just add a custom view in your application:didFinishLaunchingWithOptions:
method.
UIImageView*imageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"your_image.png"]];
[[yourFirstViewController view] addSubview:imageView];
[[yourFirstViewController view] bringSubviewToFront:imageView];
[self.window makeKeyAndVisible];
// Fade out the image
[UIView transitionWithView:self.window
duration:1.0f
options:nil
animations:^(void)
{
imageView.alpha=0.0f;
}
completion:^(BOOL finished)
{
[imageView removeFromSuperview];
}];

Rafał Sroka
- 39,540
- 23
- 113
- 143
-
What do you mean by "yourFirstViewController" like the name of the view controller that will appear after the image is shown? – msweet168 May 17 '14 at 22:19
-
That's literally first view controller that you show. The initial view controller. – Rafał Sroka May 17 '14 at 22:21
-
Im getting a warning with nil, and a warning and error with both of the yourFirstViewController and also the "view" after it. I still do not know what to put in your first view controller – msweet168 May 17 '14 at 22:24
-
The view error is "class method +view not found (return type defaults to 'id') – msweet168 May 17 '14 at 22:26
-
The nil error is: "incompatible pointer to integer conversion sending 'void*' to parameter of type 'UIViewAnimationOptions' – msweet168 May 17 '14 at 22:28
-
Of course you are getting this errors. You have to modify my code to suit your case. Specify your initial view controller etc. – Rafał Sroka May 17 '14 at 22:30
-
0
I used a delay to set off a segue programmatically.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
[self performSelector:@selector(enterthegame) withObject:nil afterDelay:5];
}
-(void)enterthegame{
[self performSegueWithIdentifier: @"tothegame" sender: self];
}
Just make sure that you have a segue and its identifier matches your code. The button the the segue is connected to can be hidden.

msweet168
- 371
- 1
- 18