Difference between revisions of "IOS InApp"
From AdLocus
| (8 intermediate revisions by the same user not shown) | |||
| Line 2: | Line 2: | ||
InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。 | InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。 | ||
| − | == | + | == 實作 == |
| − | * | + | * #import "libAdLocus_SDK.h" |
| − | + | * @property (nonatomic, strong) ALBannerView *alBannerView; | |
| − | ** | + | * (NSString *)AdLocusAppKey |
| − | * | + | |
| − | + | ||
| − | === ViewController.h === | + | == 啟動版位 == |
| + | <syntaxhighlight lang="objc"> | ||
| + | self.alBannerView = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; | ||
| + | self.alBannerView.delegate = self; | ||
| + | [self.alBannerView setBannerAnimationType:AdLocusBannerAnimationTypeRandom]; | ||
| + | [self.alBannerView setAutoRefreshWithTime:15]; | ||
| + | [self.alBannerView requestAdViewWithDelegate:self]; | ||
| + | [self.view addSubview:self.alBannerView]; | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | * 設定監聽 | ||
| + | <syntaxhighlight lang="objc"> | ||
| + | -(UIViewController *)viewControllerForPresentingModalView{ | ||
| + | return self; | ||
| + | } | ||
| + | </syntaxhighlight> | ||
| + | |||
| + | === 範例: ViewController.h === | ||
<syntaxhighlight lang="objc"> | <syntaxhighlight lang="objc"> | ||
#import <UIKit/UIKit.h> | #import <UIKit/UIKit.h> | ||
#import "libAdLocus_SDK.h" | #import "libAdLocus_SDK.h" | ||
| − | @interface ViewController : UIViewController < | + | @interface ViewController : UIViewController <ALBannerViewDelegate> |
| − | + | ||
@property (nonatomic, strong) ALBannerView *alBannerView; | @property (nonatomic, strong) ALBannerView *alBannerView; | ||
| − | |||
@end | @end | ||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | === ViewController.m === | + | === 範例: ViewController.m === |
<syntaxhighlight lang="objc"> | <syntaxhighlight lang="objc"> | ||
| Line 36: | Line 49: | ||
- (void)initAdLocusBannerView | - (void)initAdLocusBannerView | ||
{ | { | ||
| − | self. | + | self.alBannerView = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; |
| − | self. | + | self.alBannerView.delegate = self; |
| − | [self. | + | [self.alBannerView setBannerAnimationType:AdLocusBannerAnimationTypeRandom]; |
| − | [self. | + | [self.alBannerView setAutoRefreshWithTime:15]; |
| − | [self. | + | [self.alBannerView requestAdViewWithDelegate:self]; |
| − | + | ||
| − | [self.view addSubview:self. | + | [self.view addSubview:self.alBannerView]; |
} | } | ||
| − | |||
| − | |||
- (NSString *)AdLocusAppKey | - (NSString *)AdLocusAppKey | ||
{ | { | ||
| Line 52: | Line 63: | ||
} | } | ||
| + | |||
| + | </syntaxhighlight> | ||
| + | |||
| + | == 若您需要監聽廣告互動結果 == | ||
| + | 透過實作 ALBannerViewDelegate 監測廣告運行結果 | ||
| + | |||
| + | * adViewDidReceiveAd | ||
| + | * adViewDidFailToReceiveAd | ||
| + | |||
| + | <syntaxhighlight lang="objc"> | ||
- (void)adViewDidReceiveAd:(ALBannerView *)view | - (void)adViewDidReceiveAd:(ALBannerView *)view | ||
{ | { | ||
| Line 61: | Line 82: | ||
NSLog(@"Failed receive AdLocus banner Ad : %@", error); | NSLog(@"Failed receive AdLocus banner Ad : %@", error); | ||
} | } | ||
| − | |||
| − | |||
</syntaxhighlight> | </syntaxhighlight> | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 18:36, 2 September 2015
前言
InApp 版位為最常見的版位,AdLocus 提供您 320x50, 300x250, 728x90 三種不同尺寸的選擇。
實作
- #import "libAdLocus_SDK.h"
- @property (nonatomic, strong) ALBannerView *alBannerView;
- (NSString *)AdLocusAppKey
啟動版位
self.alBannerView = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; self.alBannerView.delegate = self; [self.alBannerView setBannerAnimationType:AdLocusBannerAnimationTypeRandom]; [self.alBannerView setAutoRefreshWithTime:15]; [self.alBannerView requestAdViewWithDelegate:self]; [self.view addSubview:self.alBannerView];
- 設定監聽
-(UIViewController *)viewControllerForPresentingModalView{ return self; }
範例: ViewController.h
#import <UIKit/UIKit.h> #import "libAdLocus_SDK.h" @interface ViewController : UIViewController <ALBannerViewDelegate> @property (nonatomic, strong) ALBannerView *alBannerView; @end
範例: ViewController.m
#import "ViewController.h" @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; [self initAdLocusBannerView]; } - (void)initAdLocusBannerView { self.alBannerView = [[ALBannerView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; self.alBannerView.delegate = self; [self.alBannerView setBannerAnimationType:AdLocusBannerAnimationTypeRandom]; [self.alBannerView setAutoRefreshWithTime:15]; [self.alBannerView requestAdViewWithDelegate:self]; [self.view addSubview:self.alBannerView]; } - (NSString *)AdLocusAppKey { return @"請輸入您的APPKEY"; }
若您需要監聽廣告互動結果
透過實作 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); }