1

I have a TabBarController with four view controllers . In my first view controller i have the following two methods:

-(void)loadclistview
{
    [self.tabBarController setSelectedIndex:2];
}

-(void)loadglistview
{
    [self.tabBarController setSelectedIndex:1];
}

I use them to change the view form one tab to the other. But changing tabs this way doesn't preserve my banner view, it does not load the banner into the new view controllers (tabs). If i change tabs using the tab bar , all the views load banners correctly. Pls help me here - i don't know why this is happening , and what should i do to switch tabs through selectors so that the banner will load in the new views.

EDIT:

I solved it by adding the current bannerview as a subview to the selected viewcontroller from the tab bar ; like this:

[self.tabBarController.selectedViewController.view addSubview:_bannerView];

I saw this also works to adding the bannerview to subsequent view to a navigationcontroller - like showing the banner in child views of the main view which constitues a tab;

[self.navigationController.view addSubview:_bannerView];

1 Answer 1

1

Adding the subview this way is fine, but you also have to handle the show/hide of it when there is or isn't an iAd, and the resize of the content view to make room for displaying the subview. The TabbedBanner project in the Apple iAdSuite sample has a nice encapsulation of this functionality.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.