檢視 Interstitial Ads 的原始碼
←
Interstitial Ads
跳至導覽
跳至搜尋
由於下列原因,您沒有權限進行編輯此頁面的動作:
您請求的操作只有這個群組的使用者能使用:
使用者
您可以檢視並複製此頁面的原始碼。
Interstitial廣告可以在app啟動, 視頻載入期間或遊戲暫停的時候,呈現內容豐富的HTML5網頁或Web App。。<br> 以下將告訴您如何讓您的app顯示Interstitial廣告。 == 增加TWMTAMediaInterstitialView == TWMTAMediaInterstitialView是NSObject的子類別,透過以下步驟可以很簡單的將Interstitial廣告加入App中: :* Import TWMTAMediaInterstitialView.h :* 宣告一個TWMTAMediaInterstitialView的實體在顯示Interstitial廣告的UIViewController :* alloc & init TWMTAMediaInterstitialView :* 載入廣告 #import "TWMTAMediaViewController.h" #import "TWMTAMediaView.h" #import "TWMTAMediaInterstitialView.h" @interface TWMTAMediaViewController () <TWMTAMediaViewDelegate, TWMTAMediaInterstitialViewDelegate> { TWMTAMediaView *_adView; TWMTAMediaInterstitialView *_interstitialView; } @end @implementation TWMTAMediaViewController //@synthesize _adView; - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. CGRect frame = CGRectMake(0, 0, [UIScreen mainScreen].applicationFrame.size.width, [UIScreen mainScreen].applicationFrame.size.height); _interstitialView = [[TWMTAMediaInterstitialView alloc] initWithFrame:frame slotId:@"h0Lz1374718054864uDt" developerID:@"" gpsEnabled:YES testMode:NO]; [_interstitialView receiveAd]; } @end 當Interstitial廣告載入完成且要呈現時才需要呼叫showAd:方法 [_interstitialView showAd:self.view]; == TWMTAMediaInterstitialViewDelegate == 你可以選擇透過實現全部或部分的TWMTAMediaInterstitialViewDelegate方法來追踪Interstitial廣告的生命週期 @protocol TWMTAMediaInterstitialViewDelegate <NSObject> @optional - (void)interstitialViewWillLoadAd:(TWMTAMediaInterstitialView *)view; - (void)interstitialViewDidLoadAd:(TWMTAMediaInterstitialView *)view; - (void)interstitialView:(TWMTAMediaInterstitialView *)view didFailToReceiveAdWithError:(NSError *)error; - (BOOL)interstitialViewActionShouldBegin:(TWMTAMediaInterstitialView *)view willLeaveApplication:(BOOL)willLeave; - (void)interstitialViewWillDisappear:(TWMTAMediaInterstitialView *)view; - (void)interstitialViewDidDisappear:(TWMTAMediaInterstitialView *)view; @end 你可以在UIViewController中實現TWMTAMediaInterstitialViewDelegate方法 #import "TWMTAMediaViewController.h" #import "TWMTAMediaInterstitialView.h" @interface TWMTAMediaViewController () <TWMTAMediaInterstitialViewDelegate> { } @end 並且透過TWMTAMediaInterstitialView的setDelegate:方法來指定實現TWMTAMediaInterstitialViewDelegate的對象 [_interstitialView setDelegate:self]; 請注意,如果你有實現TWMTAMediaInterstitialViewDelegate,當TWMTAMediaInterstitialView不再被使用時,必須將delegate設定為nil - (void)dealloc { _interstitialView.delegate = nil; // Don't release the _adView if you are using ARC in your project [_interstitialView release]; _interstitialView = nil; } ==== - (void)interstitialViewWillLoadAd:(TWMTAMediaInterstitialView *)view ==== TWMTAMediaInterstitialView開始載入廣告前會先呼叫這個方法 - (void)interstitialViewWillLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewWillLoadAd", view); } ==== - (void)interstitialViewDidLoadAd:(TWMTAMediaInterstitialView *)view ==== 你可以在確定廣告已經載入後才將TWMTAMediaInterstitialView加入UI - (void)interstitialViewDidLoadAd:(TWMTAMediaInterstitialView *)view { NSLog(@"%@ interstitialViewDidLoadAd", view); [_interstitialView showAd:self.view]; } ==== - (void)interstitialView:(TWMTAMediaInterstitialView *)view didFailToReceiveAdWithError:(NSError *)error ==== 你可以在這裡的得知載入廣告過程中發生的何異常 - (void)interstitialView:(TWMTAMediaInterstitialView *)view didFailToReceiveAdWithError:(NSError *)error { NSLog(@"%@ interstitialViewdidFailToReceiveAdWithError:%@", view, error.description); } ==== - (BOOL)interstitialViewActionShouldBegin:(TWMTAMediaInterstitialView *)view willLeaveApplication:(BOOL)willLeave ==== 當使用者點擊廣告後,TWMTAMediaView在開啟網頁或App Store前會先通知你 - (BOOL)interstitialViewActionShouldBegin:(TWMTAMediaInterstitialView *)view willLeaveApplication:(BOOL)willLeave { NSLog(@"%@ interstitialViewwillLeaveApplication:%i", view, willLeave); return YES; }
返回到「
Interstitial Ads
」。
導覽選單
個人工具
登入
命名空間
頁面
討論
變體
已展開
已摺疊
視圖
閱讀
檢視原始碼
檢視歷史
更多
已展開
已摺疊
搜尋
導覽
首頁
近期變更
隨機頁面
有關 MediaWiki 的說明
工具
連結至此的頁面
相關變更
特殊頁面
頁面資訊