0

目標: 特定の時間 (3 秒) でスプラッシュ スクリーンを表示し、認証プロセスのためにログイン ビューが表示され、この認証が成功するとメイン ページに移動します (この効果は facebook などの多くのアプリケーションで使用されます)。

私がしていることは

1.ナビゲーションのルートをMainViewController

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  self.isLogIn = FALSE;
  self.window  =   [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  MainViewController    *mainView      =   [[MainViewController alloc]   initWithNibName:@"MainViewController" bundle:nil];
  self.navigationController            =   [[UINavigationController alloc] initWithRootViewController:mainView];
  self.window.rootViewController       =   navigationController;
  [self.window makeKeyAndVisible];
  return YES;

}

2. modalViewControllerLogInViewControllerとして存在するMainViewController

@implementation MainViewController
-(void) viewDidLoad {
  appDelegate                        =   [[UIApplication sharedApplication] delegate];
  LogInController   *logInController =   [[LogInController alloc]                 initWithNibName:@"LogInController"      bundle:nil];

  if ( !appDelegate.isLogIn )
     [self presentModalViewController:logInController animated:NO]; 
}

3. modalViewControllersplashScreenとして存在するLogInViewController

#implementation LogInViewController
-(void)viewDidLoad
{
    [super viewDidLoad];
    self.title                     =   @"Sign in";
    SplashScreen *splashController =   [[SplashScreen alloc]           initWithNibName:@"SplashScreen"         bundle:nil];

    [self presentModalViewController:splashController animated:NO];
    ;
}

}

4.splashScreen で、一定時間後に自分自身を閉じる

@implementation SplashScreen
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self performSelector:@selector(removeSplashScreen) withObject:nil afterDelay:6.0];                         

}

-(void)removeSplashScreen{
    [self dismissViewControllerAnimated:YES completion:nil];
} 

問題: ログイン ビューは表示されますが、ログイン ビューの前にスプラッシュスクリーンが表示されません。

viewDidLoadofのメソッドSplashScreenがまったく呼び出されていないことがわかりました。

誰かが私にそれを説明して、私がここで見逃していることを指摘できますか. ここではすべてのコメントを歓迎します。

4

1 に答える 1

1

appDelegate の参照に問題があるため、これを行います

@implementation MainViewController
-(void) viewDidLoad {
   appDelegate                        =   (YourAppDelegate *)[[UIApplication sharedApplication] delegate];
   LogInController   *logInController =   [[LogInController alloc]                 initWithNibName:@"LogInController"      bundle:nil];

   if ( !appDelegate.isLogIn )
   [self presentModalViewController:logInController animated:NO]; 
 }
于 2012-09-14T04:42:37.143 に答える