Objective-C, Adwhirl banner in Interface Builder

2020-08-04 04:18发布

Does anyone have any suggestions on how to make a AdWhirl banner in interface builder? Right now I use this code to make a banner:

 AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self]; 

[self.view addSubview:awView];

awView.frame = CGRectMake(0, 361, kAdWhirlViewWidth, kAdWhirlViewHeight);

I've tried to make a UIView and making an IBOutlet to it and making it's class a AdWhirlView but I can't seem to get it right...

Thanks

2条回答
我只想做你的唯一
2楼-- · 2020-08-04 04:23

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.

enter image description here

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.

查看更多
Bombasti
3楼-- · 2020-08-04 04:36

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

查看更多
登录 后发表回答