2

I am developing the school application and admin panel. On first time open application it will to show My company's splash-screen, in my app i am giving login credentials for parents. After login into app it will register that user to particular school. Next time when user open the app it should show particular school splash-screen what ever that school is added in admin panel.

If is it possible? How it can be achieved?

Thanks in advance.

M Zubair Shamshad
  • 2,741
  • 3
  • 23
  • 45
bAthi
  • 341
  • 4
  • 20

3 Answers3

4

yes its possible you should use the custom splash screen view controller. Please refer the below link and follow the steps.

https://nullpointr.wordpress.com/2012/02/19/iphone-dev-how-to-implement-a-splash-screen/

or

UIImageView*imageView=[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"your_default_image_or_another.png"]];
[[firstViewController view] addSubview:imageView];
[[firstViewController view] bringSubviewToFront:imageView];

// as usual
[self.window makeKeyAndVisible];

//now fade out splash image
[UIView transitionWithView:self.window duration:1.0f options:UIViewAnimationOptionTransitionNone animations:^(void){imageView.alpha=0.0f;} completion:^(BOOL finished){[imageView removeFromSuperview];}];

In this you can use your own image or download image from web service for different school and set here in imageview.

BKjadav
  • 543
  • 2
  • 16
3

In first time open application it has to show My company splash screen, in my app I am given login credentials for parents. After login into app it has to register that user to particular school.

An easy way to go about this would be to set a BOOL in your AppDelegate to test if it's the first launch of your app.

In AppDelegate.m you could check if it's the first load of the app by doing something like this in

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Check if app has loaded before
    [self checkUserDefaults];
    // Another method to determine what the first screen the user sees is
    [self setInitialViewController];
    return YES;
}

...further down you could do something like this

// make a section for UserDefaults
#pragma mark - User Defaults

- (void)checkUserDefaults {

    if (![[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"])
    {
        [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"hasLaunchedOnce"];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }

Next time user open app it has to show particular school splash screen what ever that school is added in admin panel. If is possible? How?

You could also create a method in AppDelegate that determines where to go next, based on NSUserDefaults:

- (void)setInitialViewController {
    UIStoryboard *storyboard = self.window.rootViewController.storyboard;

    // Check if there's a key created or if the key exists
    if ([[[NSUserDefaults standardUserDefaults]valueForKey:@"hasLaunchedOnce"]boolValue] == NO || ![[NSUserDefaults standardUserDefaults] boolForKey:@"hasLaunchedOnce"]) {
        // set to instantiate first launch VC
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"initialVC"];
        self.window.rootViewController = rootViewController;
    } else {
        UIViewController *rootViewController = [storyboard instantiateViewControllerWithIdentifier:@"schoolSelectedVC"];
        self.window.rootViewController = rootViewController;
    }
    [self.window makeKeyAndVisible];
}

Somewhere down the line on your Initial Scene, you'd want to update your NSUserDefaults to reflect that it's configured for that a school is selected.

        [[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"hasLaunchedOnce"];
Community
  • 1
  • 1
Adrian
  • 16,233
  • 18
  • 112
  • 180
0

use your own splash screen view controller.

use userdeafult to save that state of it -like if you want it to work only one time or only everytime the app wasn't in the memory-

use delegate methods or notification centre -any thing with call back function - or normal method and check the conditions you need and with each condition change the UI as you need by show/hide , UIAnimation or even refresh the whole UI

hope this can help you.

ahmedHegazi
  • 190
  • 1
  • 14