-
Notifications
You must be signed in to change notification settings - Fork 0
ios advanced usage
Last SDK Version: 2.1.0
###Controlling the size of your banner The size of the banner is determined by the "size" parameter which can receive one of the following values| Value | Size | Best fits for |
|---|---|---|
STA_AutoAdSize |
Auto-size (recommended) | detects the width of the device's screen in its current orientation, and provides the optimal banner for this size |
STA_PortraitAdSize_320x50 |
320x50 | iPhone/iPod touch in portrait mode |
STA_LandscapeAdSize_480x50 |
480x50 | iPhone/iPod touch in landscape mode |
STA_PortraitAdSize_768x90 |
768x90 | iPad in portrait mode |
STA_LandscapeAdSize_1024x90 |
1024x90 | iPad in landscape mode |
- Add the STABannerDelegagteProtocol to the header file
@interface YourViewController : UIViewController <STABannerDelegagteProtocol>
{
STABannerView* bannerView;
} - Use "withDelegate:self" when initializing the STABannerView object:
bannerView = [[STABannerView alloc] initWithSize:STA_AutoAdSize
autoOrigin:STAAdOrigin_Top
withView:self.view
withDelegate:self];- Implement the following functions:
- (void) didDisplayBannerAd:(STABannerView*)banner;
- (void) failedLoadBannerAd:(STABannerView*)banner withError:(NSError *)error;
- (void) didClickBannerAd:(STABannerView*)banner;Locating your banner 100 pixels above the view's bottom:
bannerView = [[STABannerView alloc] initWithSize:STA_AutoAdSize
origin:CGPointMake(0, self.view.frame.size.height - 100)
withView:self.view
withDelegate:nil];To use a different banner origin in a specific layout, call the "setOrigin"/"setStartAppAutoOrigin" with the new origin value.
###Changing the banner size and origin upon rotation If you choose to manually control the banner's size & origin upon rotation, you can do it in the didRotateFromInterfaceOrientation function.Example:
// YourViewController.m
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
if (UIInterfaceOrientationIsPortrait(self.interfaceOrientation)) {
[bannerView setOrigin:CGPointMake(0, 0)];
} else {
[bannerView setOrigin:CGPointMake(0, 300)];
}
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}- Add the STADelegateProtocol to the header file
@interface YourViewController : UIViewController <STADelegateProtocol>
{
STAStartAppAd* startAppAd;
} -
Use "withDelegate:self" when calling the loadAd function:
[startAppAd loadAd:STAAdType_Automatic withDelegate:self] -
Implement the following functions:
- (void) didLoadAd:(STAAbstractAd*)ad;
- (void) failedLoadAd:(STAAbstractAd*)ad withError:(NSError *)error;
- (void) didShowAd:(STAAbstractAd*)ad;
- (void) failedShowAd:(STAAbstractAd*)ad withError:(NSError *)error;
- (void) didCloseAd:(STAAbstractAd*)ad;The options for this parameter are:
| Constant Name | Description | Specific Ad Load Example |
|---|---|---|
STAAdType_FullScreen |
A full-page ad | [startAppAd loadAd:STAAdType_FullScreen ]; |
STAAdType_OfferWall |
A full page offerwall | [startAppAd loadAd:STAAdType_OfferWall ]; |
STAAdType_Overlay |
An overlay Ad is a full page Ad that runs on top of your application | [startAppAd loadAd:STAAdType_Overlay ]; |
- Declare an STABannerView instance variable in your UITableView class
@interface YourViewController ()
{
STABannerView* bannerview;
}
@end- Override the
cellForRowAtIndexPathmethod, and add the required code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell=nil;
cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
// ADD THE FOLLOWING LINES
if(bannerview == nil)
{
bannerview = [[STABannerView alloc] initWithSize:STA_AutoAdSize autoOrigin:STAAdOrigin_Top withView:cell withDelegate:self];
}
[bannerview addSTABannerToCell:cell withIndexPath:indexPath atIntexPathRow:2 repeatEach:8];
return cell;
}Use the addSTABannerToCell method to set the banner's position and frequency:
-
atIntexPathRow- set the cell where you want to show the banner -
repeatEach- set repetition frequency
In the above example, the banner will be displayed at the second cell, and will be repeated each 8 cells.
Step 1, Adding the StartApp SDK to your project
Enjoy Higher eCPM with Demographic-Targeted Ads
Advanced Usage
Hiding your banner
Controlling the size of your banner
Using banner delegates
Using a fixed origin for your banner
Changing the banner size and origin upon rotation
Using Interstitial delegates
Explicitly selecting the type of interstitial ad to load
Customizing your Splash Screen
Showing banners in UITableView