Difference between revisions of "IOS InApp 4.1.0"

From AdLocus
Jump to: navigation, search
(Created page with "== 前言 == InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。 == 實作 == * #import <AdLocus/AdLocus.h> == 啟...")
 
Line 17: Line 17:
  
 
* 設定監聽
 
* 設定監聽
<syntaxhighlight lang="objc">
 
-(UIViewController *)viewControllerForPresentingModalView{
 
  return self;
 
}
 
</syntaxhighlight>
 
  
 
=== 範例: ViewController.h ===
 
=== 範例: ViewController.h ===
Line 49: Line 44:
 
{
 
{
 
     self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
 
     self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    self.banner.delegate = self;
 
 
     [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
 
     [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
 
     [self.banner setAutoRefreshWithTime:15];
 
     [self.banner setAutoRefreshWithTime:15];

Revision as of 11:46, 1 June 2016

前言

InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。

實作

  • #import <AdLocus/AdLocus.h>

啟動版位

    self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    self.banner.delegate = self;
    self.banner.key = @"請填入您的APP KEY";
    [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
    [self.banner setAutoRefreshWithTime:15];
    [self.banner requestAdViewWithDelegate:self];
    [self.view addSubview:self.banner];
  • 設定監聽

範例: ViewController.h

#import <UIKit/UIKit.h>
#import <AdLocus/AdLocus.h>
 
@interface ViewController : UIViewController <ALBannerViewDelegate>
@property (nonatomic, strong) ALBannerView *banner;
@end

範例: ViewController.m

#import "ViewController.h"
 
@implementation ViewController
 
- (void)viewDidLoad
{
    [super viewDidLoad];
    [self initAdLocusBannerView];
}
 
- (void)initAdLocusBannerView
{
    self.banner = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)];
    [self.banner setBannerAnimationType:AdLocusBannerAnimationTypeRandom];
    [self.banner setAutoRefreshWithTime:15];
    [self.banner requestAdViewWithDelegate:self];
 
    [self.view addSubview:self.banner];
}

若您需要監聽廣告互動結果

透過實作 ALBannerViewDelegate 監測廣告運行結果

  • adViewDidReceiveAd
  • adViewDidFailToReceiveAd
- (void)adViewDidReceiveAd:(ALBannerView *)view
{
    NSLog(@"Receive AdLocus banner Ad.");
}
 
- (void)adViewDidFailToReceiveAd:(ALBannerView *)view andError:(HyxenAdLocusError *)error
{
    NSLog(@"Failed receive AdLocus banner Ad : %@", error);
}