Banner Ads I
跳至導覽
跳至搜尋
Banner廣告佔用屏幕的一小部分來吸引用戶的注意,並且透過點擊的方式來打開一個網站或App Store。
以下將告訴您如何讓您的app顯示Banner廣告。
增加TWMTAMediaView
TWMTAMediaView是UIView的子類別,透過以下步驟可以很簡單的將Banner廣告加入App中:
- Import TWMTAMediaView.h
- 宣告一個TWMTAMediaView的實體在顯示Banner廣告的UIViewController
- alloc & init TWMTAMediaView
- 將TWMTAMediaView加入UI
- 載入廣告
#import "TWMTAMediaViewController.h" #import "TWMTAMediaView.h" @interface TWMTAMediaViewController () <TWMTAMediaViewDelegate> { TWMTAMediaView *_adView; } @end @implementation TWMTAMediaViewController - (void)viewDidLoad { [super viewDidLoad]; _adView = [[TWMTAMediaView alloc] initWithFrame:CGRectMake(0, 0, 320, 50) slotId:@"70mQH1335375881000QAr" developerID:@"" gpsEnabled:YES testMode:NO]; [self.view addSubview:_adView]; [_adView receiveAd]; } - (void)dealloc { _adView.delegate = nil; // Don't release the _adView if you are using ARC in your project [_adView release]; _adView = nil; } @end