{"id":588,"date":"2018-02-23T23:40:14","date_gmt":"2018-02-23T15:40:14","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/ios%e6%95%b4%e5%90%88iad\/"},"modified":"2018-02-23T23:40:14","modified_gmt":"2018-02-23T15:40:14","slug":"ios%e6%95%b4%e5%90%88iad","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=588","title":{"rendered":"iOS\u6574\u5408iAD"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>IOS iAD\u6574\u5408<\/h1>\n<hr>\n<h2>\u7b80\u4ecb<\/h2>\n<p>IAD\u662f\u82f9\u679c\u63a8\u51fa\u7684\u5e7f\u544a\u5e73\u53f0\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u4ece\u5e94\u7528\u7a0b\u5e8f\u4e2d\u83b7\u53d6\u6536\u5165\u3002<\/p>\n<h3>\u5b9e\u4f8b\u6b65\u9aa4<\/h3>\n<p>1. \u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684View based application<\/p>\n<p>2. \u9009\u62e9\u9879\u76ee\u6587\u4ef6\uff0c\u7136\u540e\u9009\u62e9\u76ee\u6807\uff0c\u7136\u540e\u9009\u62e9\u6846\u67b6\u5e76\u6dfb\u52a0 iAd.framework\u3002<\/p>\n<p>3. \u66f4\u65b0 ViewController.h \u5982\u4e0b\u6240\u793a<\/p>\n<pre>\n#import &lt;UIKit\/UIKit.h&gt;\n#import &lt;iAd\/iAd.h&gt;\n@interface ViewController : UIViewController&lt;ADBannerViewDelegate&gt;\n{\n    ADBannerView *bannerView;\n}\n@end\n<\/pre>\n<p>4. \u66f4\u65b0ViewController.m \uff0c\u5982\u4e0b\u6240\u793a<\/p>\n<pre>\n#import \"ViewController.h\"\n\n@interface ViewController ()\n\n@end\n\n@implementation ViewController\n\n- (void)viewDidLoad\n{\n    [super viewDidLoad];\n    bannerView = [[ADBannerView alloc]initWithFrame:\n    CGRectMake(0, 0, 320, 50)];\n    \/\/ Optional to set background color to clear color\n    [bannerView setBackgroundColor:[UIColor clearColor]];\n    [self.view addSubview: bannerView];\n}\n\n- (void)didReceiveMemoryWarning\n{\n    [super didReceiveMemoryWarning];\n    \/\/ Dispose of any resources that can be recreated.\n}\n\n#pragma mark - AdViewDelegates\n\n-(void)bannerView:(ADBannerView *)banner \n didFailToReceiveAdWithError:(NSError *)error{\n    NSLog(@\"Error loading\");\n}\n\n-(void)bannerViewDidLoadAd:(ADBannerView *)banner{\n    NSLog(@\"Ad loaded\");\n}\n-(void)bannerViewWillLoadAd:(ADBannerView *)banner{\n    NSLog(@\"Ad will load\");\n}\n-(void)bannerViewActionDidFinish:(ADBannerView *)banner{\n    NSLog(@\"Ad did finish\");\n\n}\n@end\n<\/pre>\n<h3>\u8f93\u51fa<\/h3>\n<p>\u8fd0\u884c\u8be5\u5e94\u7528\u7a0b\u5e8f,\u5f97\u5230\u5982\u4e0b\u8f93\u51fa\u7ed3\u679c:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"attachment-full\" alt=\"iAdOutput\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2013\/11\/iAdOutput.jpg\" width=\"250\" height=\"497\" data-pinit=\"registered\"><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">IOS iAD\u6574\u5408 \u7b80\u4ecb IAD\u662f\u82f9\u679c\u63a8\u51fa\u7684\u5e7f\u544a\u5e73\u53f0\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u8005\u4ece\u5e94\u7528\u7a0b\u5e8f\u4e2d\u83b7\u53d6\u6536\u5165&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=588\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,26],"tags":[74,93],"class_list":["post-588","post","type-post","status-publish","format-standard","hentry","category-ios","category-mobile","tag-ios","tag-mobile","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/588","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=588"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/588\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=588"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=588"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=588"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}