2013-01-15 1 views
1

J'utilise Vserv complete sdk pour l'ajout d'une extension. J'appelle mon adViewController pour présenter mon add.if si l'échec échoue, je passe à un SplashViewController de mon addViewController.But je reçois cet avertissement
Warning: Attempt to present <SplashViewController: 0x1dd697b0> on <AdViewController: 0x1dd68690> whose view is not in the window hierarchy! et pas en mesure de naviguer vers ma prochaine vue qui est SplashViewController..J'ai essayé toutes les méthodes ci-dessous est le code.Pour vous les gars m'aider:Avertissement: Tenter de présenter ViewController dont la vue n'est pas présente dans la hiérarchie des fenêtres

AdViewController.m

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 

    // Do any additional setup after loading the view from its nib. 
} 

-(void)viewDidAppear:(BOOL)animated{ 
    [super viewDidAppear:animated]; 
    if([Util isInternetAvailable]) 
    { 
     //Initializes SDK 
     [VservAdManager initializeSDK]; 

     CGRect frame1; 

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) 
      frame1 = CGRectMake(0,0,1024,768); 

     else 
      frame1 = CGRectMake(0,0,320,480); 

     vservAdView = [[VservAdView alloc] initWithFrame:frame1]; 

     [vservAdView requestAd:self:@"7825":nil]; 

     [self.view addSubview: vservAdView]; 
    } 
    else{ 

     appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; 
     appDelegate.window.rootViewController = appDelegate.splashViewController; 
     [self presentModalViewController:appDelegate.splashViewController animated:NO]; 
    } 
} 

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

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
    } 
    else { 
     return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
    } 
} 

- (void)adReceivedNotification:(VservAdView*)vservAd{ 
    NSLog(@"adReceivedNotification"); 
} 

- (void)adFailedNotification:(VservAdView*)vservAd{ 
    NSLog(@"adFailedNotification"); 
    appDelegate.window.rootViewController = appDelegate.splashViewController; 
    [self presentViewController:appDelegate.splashViewController animated:NO completion:Nil]; 

} 

- (void)adSkipedNotification:(VservAdView*)vservAd{ 
    NSLog(@"adSkipedNotification"); 
    appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; 
    appDelegate.window.rootViewController = appDelegate.splashViewController; 
    [self presentModalViewController:appDelegate.splashViewController animated:NO]; 
} 

SplashViewController.h

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

-(void)viewDidAppear:(BOOL)animated{ 
    [super viewDidAppear:animated]; 
    [self setupMovie]; 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) { 
     return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
    } 
    else { 
     return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown); 
    } 
} 

-(void)setupMovie{ 
    NSLog(@"setup Movie"); 
    NSString* moviePath = [[NSBundle mainBundle] pathForResource:@"Splash" ofType:@"mp4"]; 
    NSURL* movieURL = [NSURL fileURLWithPath:moviePath]; 

    playerCtrl = [[MPMoviePlayerController alloc] initWithContentURL:movieURL]; 
    playerCtrl.scalingMode = MPMovieScalingModeFill; 
    playerCtrl.controlStyle = MPMovieControlStyleNone; 

    // playerCtrl.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(moviePlayBackDidFinish:) 
               name:MPMoviePlayerPlaybackDidFinishNotification object:nil]; 

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad){ 
     [playerCtrl.view setFrame:CGRectMake(0, 0, 1024, 768)]; 
    } 
    else{ 
     [playerCtrl.view setFrame:CGRectMake(0, 120, 320, 240)]; 
     } 

// [playerCtrl.view setTransform:CGAffineTransformMakeRotation(-M_PI/2)]; 

    [self.view addSubview:playerCtrl.view]; 
    [playerCtrl setRepeatMode:MPMovieRepeatModeNone]; 
    [playerCtrl play]; 
} 

-(IBAction)moviePlayBackDidFinish:(id)sender{ 
    AppDelegate *appDelegate = (AppDelegate*)[[UIApplication sharedApplication] delegate]; 
    [self presentModalViewController:appDelegate.revealController animated:NO]; 
    appDelegate.window.rootViewController = appDelegate.revealController; 
} 

Répondre

0

Pourquoi vous présenterez vue sur l'auto si vous définissez la vue racine des fenêtres à splashViewController?

appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; 
appDelegate.window.rootViewController = appDelegate.splashViewController; 
[self presentModalViewController:appDelegate.splashViewController animated:NO]; 

utiliser cette place

appDelegate = (AppDelegate *) [[UIApplication sharedApplication] delegate]; 
//appDelegate.window.rootViewController = appDelegate.splashViewController; 
[appDelegate.window presentModalViewController:appDelegate.splashViewController animated:NO]; 
+0

si je ne suis pas commenter la deuxième ligne. le problème que je fais face est je ne serai pas capable de naviguer de mon splashviewcontroller à mon firstviewcontroller ... son va quelque chose comme ça quand je charge mon application je vais obtenir l'ajouter dans mon adviewcontroller si l'ajout échoue .. je charge l'écran splash joue une vidéo et puis charger mon firstviewcontroller..si je commente la deuxième ligne son coincé avec le blackscreen quand mon ajout échoue.if im à décommenter et quand l'ajout échoue .. il charge le firstviewcontroller sans montrer la vidéo de splashviewcontroller .. ce que je vouloir est de lire la vidéo et charger le premier – user578386

Questions connexes