0

I am using adBanner in my application which is at bottom of the screen and I am using tableview in my application.

I have established "Horizontal spacing" relation between adBannerView and tableview. Now my problem is before loading the advertisement in adBannerView I can see white space at the bottom of the screen but I want that my tableview cover that space before loading adBannerView and when adBannerView is loaded then my tableview should move up 50 pixels. How can I achieve this?

Any idea?

iPhone
  • 4,092
  • 3
  • 34
  • 58
  • use constant property of constraints – Bhavin Bhadani Aug 10 '15 at 06:52
  • Are You using autolayout in your application? – abrar ul haq Aug 10 '15 at 07:21
  • In autolayout you can't set frame of view programmatically. I used hacks in my applications to adjust frame. I added two views one with full height and one with height - ad banner height. in Ad banner delegate methods i set frame of table view with required view e.g on ad load tableview frame = frame of view (height -ad banner view height) and before ad load set table view frame = full height view – abrar ul haq Aug 10 '15 at 07:25

2 Answers2

0

I think, you have adBanner of height 50 pixels. Set tableview's bottom space to adBanner 0 and don't set its height. Then set height for adBanner and create its constraint's property which should be initially 0 so your tableview will use that space initially. When adBannerView is loaded then set adBannerView height property 50, so tableview will automatically shift up. It may help

Bhanupriya
  • 1,202
  • 1
  • 9
  • 20
0

Set Tablview's bottom space to supreview 0 with top space, leading space and trailing space constraint. And modifiy ad banner delegate like this it will give required output. IN viewDidLoad Adbanner view alpha = 0.0

-(void)bannerViewDidLoadAd:(ADBannerView *)banner{
NSLog(@"Ad Banner did load ad.");
CGFloat height = [UIScreen mainScreen].bounds.size.height;
CGRect frame = self.viewForSource.frame;
frame.size.height = height-50;
self.viewForSource.frame = frame;
// Show the ad banner.
[UIView animateWithDuration:0.5 animations:^{
    self.adBanner.alpha = 1.0;
}];

}

-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error{
NSLog(@"Unable to show ads. Error: %@", [error localizedDescription]);
CGFloat height = [UIScreen mainScreen].bounds.size.height;
CGRect frame = self.viewForSource.frame;
frame.size.height = height;
self.viewForSource.frame = frame;
// Hide the ad banner.
[UIView animateWithDuration:0.5 animations:^{
    self.adBanner.alpha = 0.0;

}];

}

abrar ul haq
  • 404
  • 3
  • 14
  • Note take screen height if you will take tableview height it will minimise on each ad load . if you need demo app share your email id i will send you – abrar ul haq Aug 10 '15 at 08:17