我的应用程序以前运行良好,然后我添加了admob framework
,现在它崩溃了。
请检查崩溃日志,
我已经在 Google 中尝试过,但没有关于这次崩溃的结果。
如果我评论了里面的内容,viewDidAppear()
那么应用程序正在运行(不加载应用程序部分)。但是,如果我试图加载“admob”,那么它就会崩溃。
代码:
-(void)viewDidAppear:(BOOL)animated{
if([Connectivity hasConnectivity]){
// [self loadAds];
NSTimer* myTimer = [NSTimer scheduledTimerWithTimeInterval: 15.0 target: self
selector: @selector(callAfterSixtySecond:) userInfo: nil repeats: YES];
}
}
-(void) callAfterSixtySecond:(NSTimer*) t
{
if([GMMConnectivity hasConnectivity]){
[self.adBanner removeFromSuperview];
[self loadAdmob];
}
}
-(void)loadAdmob{
CGPoint origin;
if(IS_RETINA){
if([[UIScreen mainScreen] bounds].size.height >500){
// NSLog(@"5");
origin = CGPointMake(0.0,
568-
CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
}else{
// NSLog(@"4");
origin = CGPointMake(0.0,
(480)-
CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
}
}else{
// NSLog(@"3");
origin = CGPointMake(0.0,
(460)-
CGSizeFromGADAdSize(kGADAdSizeSmartBannerPortrait).height);
}
// Use predefined GADAdSize constants to define the GADBannerView.
self.adBanner = [[GADBannerView alloc] initWithAdSize:kGADAdSizeSmartBannerPortrait
origin:origin]
;
// Note: Edit SampleConstants.h to provide a definition for kSampleAdUnitID
// before compiling.
self.adBanner.adUnitID = MY_BANNER_UNIT_ID;
self.adBanner.delegate = self;
[self.adBanner setRootViewController:self];
[self.view addSubview:self.adBanner];
self.adBanner.center =
CGPointMake(self.view.center.x, self.adBanner.center.y);
[self.adBanner loadRequest:[self createRequest]];
[self.view addSubview:adBanner_];
}