当我在屏幕底部有一个AdMob视图时,我正在尝试调整tableView的大小。我尝试了几件事:Change UITableView height dynamically和Resizing UITableView When Displaying AdWhirl Ads Across Multiple Views以及Change size of UIViewTable to accommodate for AdWhirl Ad,但这些都没有奏效。没有工作,我的意思是没有发生。该视图与我尝试这些更改之前的视图完全相同。所以你知道,这个tableView
嵌套在ViewController
内。这是布局:
这是我尝试过的最后一件事:
- (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];
}
结果如下:
![在此输入图片说明] [2]
它没有显示的是,tableview
中的最后一个单元格被该广告覆盖,我正试图修复它。
答案 0 :(得分:1)
如果您想通过更新其框架来调整tableView
的大小,那么您应该关闭autolayout
模式。使用autolayout
,您应该更新约束但不更新帧。
答案 1 :(得分:0)
您应该实现updateConstraints(http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/occ/instm/UIView/updateConstraints)以指定新要求。
您可能还需要在某个时间点调用setNeedsUpdateConstraints(如果您需要显示和隐藏广告视图)。