Objective-C, Adwhirl banner in Interface Builder

扶醉桌前 提交于 2019-12-04 21:32:06

Here is the code that I use with IB:

In SecondViewController.h

@interface SecondViewController : UIViewController <AdWhirlDelegate> {


IBOutlet AdWhirlView *awView;


}

@property (nonatomic, retain) IBOutlet AdWhirlView *awView;

In SecondViewController.m

@synthesize awView;


#pragma mark AdWhirlDelegate methods

- (NSString *)adWhirlApplicationKey{
return kSampleAppKey;
}

- (UIViewController *)viewControllerForPresentingModalView{
return self;
}

And

 awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];

Then connecting the awView to a UIView in IB with the class AdWhirlView with the size 320x50

I remember i used ADWhirl in one of my projects something like this. I am just copying the code here

- (void)viewDidLoad {
    // Add the ADView.
    AdWhirlView *adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];
    // I use this tag to remove the ADWhirl view, as per my application settings (lite or paid)
    adWhirlView.tag = ADVIEW_TAG;
    adWhirlView.frame = CGRectMake(0, 412, kAdWhirlViewWidth, kAdWhirlViewHeight);
    [self.view addSubview:adWhirlView];
}

Then don't forget to implement these delegate methods.

- (NSString *)adWhirlApplicationKey {
    return @"yourADWhirlAppKey";
}

- (UIViewController *)viewControllerForPresentingModalView {
    return self;
}

Finally, also implement these delegate methods for better debugging.

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView;
- (void)adWhirlDidFailToReceiveAd:(AdWhirlView *)adWhirlView usingBackup:(BOOL)yesOrNo;

UPDATE:

I am receiving ads after using the view from IB.

But it takes the adView's rect only programatically. I mean, i put the adView in the IB in the middle, but it used to display at the top. But yeah, i get ad's.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!