Objective C
Banners
A banner is a type of ad unit that occupies a spot of a specific size (320x50, 728x90 or 300x250) within your app's layout. This type of ad unit can not be hidden. The available sizes (in dots) are the following:
- TappxBannerSizeSmartBanner: Adjusted automatically inside the device screen. The sizes you can request are: 320x50 and 728x90.
- TappxBannerSize320x50: Standard Banner for phones.
- TappxBannerSize728x90: Standard Banner for tablets.
- TappxBannerSize300x250: Also known as Mrec. Is a rectangular banner for phones and tablets.
Add to the ViewController.h file the following lines:
#import <TappxFramework/TappxAds.h>
@interface ViewController : UIViewController <TappxBannerViewControllerDelegate>
@property (retain, nonatomic) TappxBannerViewController* tappxBanner;
@end
Now in the ViewController.m file you have to initialize the Banner. Example:
#import "ViewController.h"
#import <TappxFramework/TappxAds.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
_tappxBanner = [[TappxBannerViewController alloc] initWithDelegate:self
andSize:TappxBannerSmartBanner andPosition:TappxBannerPositionBottom];
[_tappxBanner load];
}
@end
Important: To get the best memory management you must destroy the banner once used. You can do it with these lines:
if(_tappxBanner != nil)
{
[_tappxBanner removeBanner];
_tappxBanner = nil;
}
Advanced Banner
If you want to show the ad in a different position than TOP or BOTTOM, there are two options:
Setting the exact position
_tappxBanner = [[TappxBannerViewController alloc] initWithDelegate:self
andSize:TappxBannerSmartBanner andPosition:CGPointMake(X, Y)];
With an UiView
_tappxBanner = [[TappxBannerViewController alloc] initWithDelegate:self
andSize:TappxBannerSmartBanner andView:_viewTappxBanner];
Delegates
You can listen the banner events with the "delegates" functions:
-(void) tappxBannerViewControllerDidFinishLoad:(TappxBannerViewController*) vc{
NSLog(@"BANNER: DidFinishLoad");
}
-(void) tappxBannerViewControllerDidFail:(TappxBannerViewController*) viewController
withError:(TappxErrorAd*) error{
NSLog(@"BANNER: DidFail %@", error.descriptionError);
}
-(void) tappxBannerViewControllerDidPress:(TappxBannerViewController*) vc{
NSLog(@"BANNER: DidPressr");
}
-(void) tappxBannerViewControllerDidClose:(TappxBannerViewController*) vc{
NSLog(@"BANNER: DidClose");
}
Tappx © 2024