I have a UIViewController that contains a TableView and an GADBannerView at the bottom. When an ad is received I change the height of the TableView so the ad doesn't cover any cells. This worked without any problem on my iPhone 6 (iOS 10) and in the simulators (iOS 10), but for some reason when testing my app on an old iPhone 4s (iOS 9), the TableView height gets reset if I leave the view controller and then return to it. Why does this happen and how can I prevent it?
This is the code I use to resize the tableview.
- (void)adViewDidReceiveAd:(GADBannerView *)view {
if (!adRecieved) {
view.hidden = NO;
CGRect currentRect = self.tableView.frame;
currentRect.size.height -= CGRectGetHeight(view.frame);
self.tableView.frame = currentRect;
adRecieved = YES;
}
I solved the problem by just editing my table view constraints instead. Now it behaves the same way on all devices.
- (void)adViewDidReceiveAd:(GADBannerView *)view {
if (!adRecieved) {
view.hidden = NO;
self.tableViewBottom.constant = -50;
adRecieved = YES;
}
}