I need help with launch images on iphone. In the project settings on xcode theres an option to add launch images. I added it and it displays for 2 seconds... I want it to be more... How can i change it? Thanks :)
You can also do it by appliying following code in
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
[NSThread sleepForTimeInterval:2.0]; // Used For Showing Splash Screen for More Time
}
First create the viewcontroller set the image what you want to show as splash screen/Launc image..
Present that view in method applicationDidFinishLaunching: with Animated:No
and write following code in your another view that your presenting
-(void) viewWillAppear:(BOOL)animated
{
[self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f];
[super viewWillAppear:animated];
}
-(void) dismiss1
{
[self dismissModalViewControllerAnimated:NO];
}
If you want to show the splash screen every time app opens, then present the splashscreen viewcontroller in applicationDidBecomeActive method
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
/*this will pause main thread for x interval seconds.
put on the top of application:didFinishLaunchingWithOptions, so it will not
proceed to show window until sleep interval is finished.*/
[NSThread sleepForTimeInterval:2]; //add 2 seconds longer.
//other code....
}
You can also do it by appliying following code in
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
[NSThread sleepForTimeInterval:2.0]; // Used For Showing Splash Screen for More Time
}
First create the viewcontroller set the image what you want to show as splash screen/Launc image..
Present that view in method applicationDidFinishLaunching: with Animated:No
and write following code in your another view that your presenting
-(void) viewWillAppear:(BOOL)animated
{
[self performSelector:@selector(dismiss1) withObject:nil afterDelay:5.0f];
[super viewWillAppear:animated];
}
-(void) dismiss1
{
[self dismissModalViewControllerAnimated:NO];
}
If you want to show the splash screen every time app opens, then present the splashscreen viewcontroller in applicationDidBecomeActive method
You can use the sleep()
method.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
sleep(10);
return YES;
}
Launch images are there to make your app appear really responsive and should be a snapshot of your UI prior to any items on it like tabBars, etc. Apple doesn't really want you to use them as splash screens.
That said, a lot of people do and to achieve this result, your App delegate needs to put the same image on screen as you launch image and then you can delay launching your main app with performSelector:withObject:afterDelay:
In Swift
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Thread.sleep(forTimeInterval: 2.0)
return true
}
make the default view...have an image view with the same default image...and then launch the new view(main app ) after specific time using [self performselector methods
you can put a UIImageView in your very first loaded view. say, in viewDidLoad of FirstViewController
-(void)viewDidLoad{
appLogo = [UIImageView alloc]initWithImage:[UIImage imageNamed:@"companyLogo.png"]];
[appLogo setFrame:CGRectMake..... ];
self.view addSubView:appLogo];
[self performSelector:@selector(hideAppLogo) withObject:nil afterDelay:1000000 :) ];
}
-(void)hideAppLogo{
[appLogo setHidden:YES];
//let the user use your app now!
}
YOu can achieve this by adding backgroundColor of "Default.png" in window before assigning window to rootviewController and just after few seconds assign rootviewController to window and set window background color to its default.
like this -
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
[self performSelector:@selector(openLoginScreen) withObject:nil afterDelay:0.5];
self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Default.png"]];
[self.window makeKeyAndVisible];
}
-(void)openLoginScreen{
self.window = [UINavigation .... "YOUR ROOT VIEWCONTROLLER"];
}
© 2022 - 2024 — McMap. All rights reserved.