2013-01-15 27 views
1

我使用Vserv完整的SDK addintegeration.I'm打電話給我adViewController提出我add.if失敗添加失敗,我要帶去臺灣的SplashViewController從我的addViewController.But我得到這個警告
Warning: Attempt to present <SplashViewController: 0x1dd697b0> on <AdViewController: 0x1dd68690> whose view is not in the window hierarchy!,無法導航到我的下一個視圖是SplashViewController ..我試過以下所有的方法是code.Could你們幫我:警告:試圖提出ViewController中,其觀點是不存在於窗口層次

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; 
} 

回答

0

你爲什麼要提出看法自我,如果你設置窗口的根視圖splashViewController?

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

如果讀音字評論的第二行,而不是使用該

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

。我面臨的問題是,我將無法從我的splashviewcontroller導航到我的firstviewcontroller ...它是這樣的東西時,我加載我的應用我會得到我的adviewcontroller的添加,如果添加fails..i加載啓動畫面,其playes視頻,然後加載我firstviewcontroller..if我評論的第二行的套牢blackscreen當我的外接fails.if IM以取消當加fails..it加載firstviewcontroller而不顯示video..what我的splashviewcontroller要的就是播放視頻並加載firstvie – user578386

相關問題