uinavigationcontroller - iOS 7 iAds with TabBar Controller and Navigation Controller -
uinavigationcontroller - iOS 7 iAds with TabBar Controller and Navigation Controller -
i have uitabbarcontroller
, uinavigationcontroller
in app storyboards want utilize iads in. using bannerviewcontroller.h & .m files provided apple in iadsuite demo. in tabbed views without navigation controller, adbannerview
loads fine. when switch tab nav controller, there black bar (window) on bottom of screen above tab bar. when adbannerview
loads, moved on black bar , app looks fine. when fails load, black bar back. black bar on every view pushed onto nav controller stack when adbannerview
isn't showing.
how can remove black bar?
this view when adbannerview hasn't loaded yet. has bluish background way downwards tab bar. black bar has started appear when using bannerviewcontroller w/ tab bar & nav controllers when adbannerview loads
here code:
in tabbarviewcontroller.m:
//implement bannerviewcontrollers on views in tab bar cgrect screenbounds = [[uiscreen mainscreen] bounds]; uistoryboard *storyboard = nil; if (screenbounds.size.height == 568) { storyboard = [uistoryboard storyboardwithname:@"main_iphone4" bundle: nil]; } else { storyboard = [uistoryboard storyboardwithname:@"main_iphone35" bundle: nil]; } uinavigationcontroller *firstviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"navview"]; aboutviewcontroller *secondviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"aboutview"]; contactviewcontroller *thirdviewcontroller = [storyboard instantiateviewcontrollerwithidentifier:@"contactview"]; nsmutablearray *mutarray = [[nsmutablearray alloc] init]; [mutarray addobjectsfromarray:self.viewcontrollers]; [mutarray replaceobjectatindex:0 withobject:[[bannerviewcontroller alloc] initwithcontentviewcontroller:firstviewcontroller]]; [mutarray replaceobjectatindex:1 withobject:[[bannerviewcontroller alloc] initwithcontentviewcontroller:secondviewcontroller]]; [mutarray replaceobjectatindex:2 withobject:[[bannerviewcontroller alloc] initwithcontentviewcontroller:thirdviewcontroller]]; nsarray *array = [nsarray arraywitharray:mutarray]; [self setviewcontrollers:array];
taken tabbedbanner in iadsuite:
in bannerviewcontroller.m:
- (void)loadview { uiview *contentview = [[uiview alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // setup containment of _contentcontroller. [self addchildviewcontroller:_contentcontroller]; [contentview addsubview:_contentcontroller.view]; [_contentcontroller didmovetoparentviewcontroller:self]; self.view = contentview; } - (void)viewdidlayoutsubviews { cgrect contentframe = self.view.bounds, bannerframe = cgrectzero; adbannerview *bannerview = [bannerviewmanager sharedinstance].bannerview; nslog(@"content frame before layout = %@",nsstringfromcgrect(contentframe)); bannerframe.size = [bannerview sizethatfits:contentframe.size]; if (bannerview.bannerloaded) { contentframe.size.height -= bannerframe.size.height; bannerframe.origin.y = contentframe.size.height; } else { bannerframe.origin.y = contentframe.size.height; } nslog(@"content frame after layout = %@",nsstringfromcgrect(contentframe)); //_contentcontroller.view.frame = contentframe; //i commented out because adbannerview move black bar instead of covering it. // want modify banner view if view controller visible user. // prevents modifying while beingness displayed elsewhere. if (self.isviewloaded && (self.view.window != nil)) { [self.view addsubview:bannerview]; bannerview.frame = bannerframe; } }
realizing black bar window showing, extended contentcontroller's frame 50 cover up. still don't know why happening in tab+nav controller combo, here code fixed it
in bannerviewcontroller.m:
- (void)loadview { uiview *contentview = [[uiview alloc] initwithframe:[[uiscreen mainscreen] bounds]]; // setup containment of _contentcontroller. [self addchildviewcontroller:_contentcontroller]; [contentview addsubview:_contentcontroller.view]; [_contentcontroller didmovetoparentviewcontroller:self]; _contentcontroller.view.frame = cgrectmake(0, 0, 320, 618); //this saved me self.view = contentview; }
ios uinavigationcontroller uitabbarcontroller iad
Comments
Post a Comment