我已经完成了我的应用程序,最后我添加了iAd和admob。我的应用程序的工作方式如下:播放按钮,按播放按钮,然后出现滚动视图。一切正常,直到iAd开启,但当iAd停止(消失)并出现admob时,滚动视图停止滚动。当admob开启时我无法滚动。一切顺利,直到admob收到广告并出现,但如果滚动不起作用我的应用程序是无用的......请帮忙!
如果我这样做:
//[self.view addSubview:self.bannerView];
滚动工作再次正常,我的控制台显示,admob接收广告,但它不可见。
按下播放按钮时:
[UIScrollView beginAnimations:nil context:NULL];
[UIScrollView setAnimationDuration:0.5];
[skroller setAlpha:0];
[skroller setAlpha:1];
[UIScrollView commitAnimations];
[UIButton beginAnimations:nil context:NULL];
[UIButton setAnimationDuration:0.5];
[play setAlpha:1];
[play setAlpha:0];
[UIButton commitAnimations];
如果我写到这个:
[self.view addSubview:skroller];
滚动不再起作用..
我的代码是:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
self.bannerView = [[GADBannerView alloc]initWithFrame:CGRectMake(0.0, self.view.frame.size.height, GAD_SIZE_320x50.width, GAD_SIZE_320x50.height)];
self.bannerView.adUnitID = MyAdUnitID;
self.bannerView.delegate = self;
[self.bannerView setRootViewController:self];
[self.view addSubview:self.bannerView];
[self.bannerView loadRequest:[self createRequest]];
}
#pragma mark Request Generation
-(GADRequest *)createRequest{
GADRequest *request = [GADRequest request];
request.testDevices = [NSArray arrayWithObjects:GAD_SIMULATOR_ID, nil];
return request;
}
#pragma mark GADBannerViewDelegate impl
-(void)adViewDidReceiveAd:(GADBannerView *)adView{
NSLog(@"Received ad");
[UIView animateWithDuration:1.0 animations:^{
adView.frame = CGRectMake(0.0, self.view.frame.size.height - adView.frame.size.height, adView.frame.size.width, adView.frame.size.height);
}];
}
-(void)adView:(GADBannerView *)view didFailToReceiveAdWithError:(GADRequestError *)error{
NSLog(@"Failed to received ad with error : %@",[error localizedFailureReason]);
}