0

I'm trying to resize my tableView when I am have an AdMob view at the bottom of my screen. I've tried a couple things: Change UITableView height dynamically and Resizing UITableView When Displaying AdWhirl Ads Across Multiple Views and Change size of UIViewTable to accommodate for AdWhirl Ad but none of those have worked. By not worked, I mean NOTHING happens. The view is EXACTLY the same as it was before I tried those changes. So you know, this tableView is nested inside of a ViewController. Here is the layout:

enter image description here

Here is the last thing I've tried:

- (void)viewDidLoad
{
    [super viewDidLoad];
     [self.navigationController setNavigationBarHidden:NO];
#ifdef FREERECORDER
    CGPoint origin = CGPointMake(0.0,self.view.frame.size.height - 90 - CGSizeFromGADAdSize(kGADAdSizeBanner).height);
    gBannerView =[[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner
                                                origin:origin];
    //this is where I'm attempting to resize
    CGRect tableFrame = self->tableView.frame;
    tableFrame.size.height = self->tableView.frame.size.height - 500;
    self->tableView.frame = tableFrame;

    gBannerView.adUnitID = @"MY_AD_ID";
    gBannerView.rootViewController = self;
    [self.view addSubview:gBannerView];
    GADRequest *request = [GADRequest request];

    // Make the request for a test ad. Put in an identifier for
    // the simulator as well as any devices you want to receive test ads.
    request.testDevices = [NSArray arrayWithObjects:
                           @" MY_TEST_ID",
                           nil];
    [gBannerView loadRequest:[GADRequest request]];




#endif

    self.title = @"All Root Beers"; 
    RootBeerFeedParser* rfp = [[RootBeerFeedParser alloc]init];
    rootBeerList = [rfp getCoreDataRootBeers];
    self.tabBar.delegate = self;
     [self->tableView reloadData];

}

This is the result:

![enter image description here][2]

What it doesn't show, is that the last cell in the tableview is covered by that advertisement and I'm trying to fix that.

Community
  • 1
  • 1
BlackHatSamurai
  • 23,275
  • 22
  • 95
  • 156

2 Answers2

1

If you want to resize tableView by updating its frame, then you should turn off the autolayout mode. With autolayout you should update constrains but not frames.

onegray
  • 5,105
  • 1
  • 23
  • 29
  • That did work, but turning of auto layout on the tableview, turned it off for the entire app. Is it possible to have it turn off for just one of the pages on a storyboard? – BlackHatSamurai May 25 '13 at 22:37
  • 1
    You can put the screen into XIB and disable `autolayout` for it. – onegray May 25 '13 at 23:46
0

You should implement updateConstraints (http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/updateConstraints) in order to specify the new requirement.

You may also need to call setNeedsUpdateConstraints at some point in time (if you need to show and hide the ad view).

Wain
  • 118,658
  • 15
  • 128
  • 151