addintegeration に Vserv 完全な sdk を使用しています。adViewController を呼び出して add を表示しています。失敗した追加が失敗した場合、addViewController から SplashViewController を取得しています
Warning: Attempt to present <SplashViewController: 0x1dd697b0> on <AdViewController: 0x1dd68690>
whose view is not in the window hierarchy!
。次のビューは SplashViewController です。以下のすべてのメソッドを試してみましたが、コードです。
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;
}