0

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 Answers2

0

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.

  • Yeah but with this I can't decide where I want the banner in Interface Builder can I? –  Jun 02 '11 at 14:20
  • You need to have your ADWhirl view as your instance variable, and as you said have an UIView in the IB at the bottom, set its class type to ADWhirlView and connect its outlet to this ADWhirlView instance variable. –  Jun 02 '11 at 14:27
  • Ok, you mean to say it works when you do it programatically and not when have it in IB? –  Jun 02 '11 at 14:29
  • Yes praktik, that's what i mean –  Jun 02 '11 at 18:21
  • Please post the code when you do it via IB, only after properly connection the ADWhirl view to its outlet and setitng its class type in IB. –  Jun 03 '11 at 06:16
  • But in the above answer of yours, you are assigning the adwhirl view to a new instance. AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];. As you have said, you have placed the view in IB and you must have taken an outlet of that in your class. Please assign the adWhirl view to this outlet. SOmething like this, yourADWhirlOutlet = [AdWhirlView requestAdWhirlViewWithDelegate:self]; and since its frame is specified in IB, no need to do that programatically. –  Jun 03 '11 at 10:24
  • "yourADWhirlOutlet = [AdWhirlView requestAdWhirlViewWithDelegate:self];" Isn't that what I have done? –  Jun 03 '11 at 10:28
  • Wait wait wait, you missed the code, that's my question up there. Look below for the new code! –  Jun 03 '11 at 10:43
  • When I do like you did above, I get my ad's on the bottom and a white UIView where I want the ad's to be. –  Jun 03 '11 at 19:25
  • What is this white UIView? If you are getting ad's in your ADWhirlView which you used in IB, then where this white UIView is coming from? –  Jun 04 '11 at 02:14
  • Well, I don't know but the AdWhirlView didn't seem to act as it should, anyway I worked around the problem. What I wanted was a AdWhirlView at my scrollview which I thought would be easiest to get via IB, now I fixed that with this self.scrollview addSubview:awView]; It might not be the best way (I'd rather like to use IB) But it works, thank you for all the help! –  Jun 04 '11 at 10:08
0

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