2

I downloaded a copy of the adWhirl PRO sample files for iphone from www.adwhirl.com to learn how to implement adWhirl into an app.

The default postion of the ad banner is on top of the screen.

I am trying to position the banner at the bottom instead.

After searching in Google Groups, I have tried in the .m file

- (void)viewDidLoad {
    [super viewDidLoad];

    AdWhirlView *adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];

    adView.frame = CGRectMake(0, 410, kAdWhirlViewWidth, kAdWhirlViewHeight); 

    [self.view addSubview:adWhirlView];
}

But the ad Banner remains in the same position.

I also tried modifying the adWhirlView.h file, by changing:

#define kAdWhirlViewDefaultFrame \
                        (CGRectMake(0,0,kAdWhirlViewWidth, kAdWhirlViewHeight))

to

#define kAdWhirlViewDefaultFrame \
                        (CGRectMake(0,410,kAdWhirlViewWidth, kAdWhirlViewHeight))

But the adView position remains the same, on top, it does shift the ad Banner down, but it also shifts down the ad itself within the adView, such that if you changed 410 to 25, only half the ad banner will show.

screenshot

What am I doing wrong, please?

Does anyone know how to place the adView at the bottom of the screen, please?

Many Thanks

theMouse
  • 317
  • 5
  • 15

3 Answers3

9

Implement this Adwhirl delegate method

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {

    CGSize adSize = [adWhirlView actualAdSize];     
    CGRect newFrame = adWhirlView.frame;        
    newFrame.size = adSize;     
    newFrame.origin.x = (self.view.bounds.size.width - adSize.width)/ 2;        
    newFrame.origin.y=  self.view.frame.size.height - adSize.height;        
    adWhirlView.frame = newFrame;       
 }
Hector
  • 3,909
  • 2
  • 30
  • 46
Shubhank
  • 21,721
  • 8
  • 65
  • 83
  • Hi, thank you for the reply. This code in already in the AdWhirlPro_ViewController.m file and the adView is still on top of the screen. – theMouse Mar 17 '12 at 01:57
1

Just Try this:

- (void)adWhirlDidReceiveAd:(AdWhirlView *)adWhirlView {

CGRect newFrame=CGRectMake(0, 410, 320, 50);
adWhirlView.frame = newFrame;
}
Hector
  • 3,909
  • 2
  • 30
  • 46
  • Thank you for the reply. I tried it, there are 2 build errors: 1.) incompatible type for argument 1 of 'setFrame:' and 2.) incompatible types in initialization – theMouse Mar 18 '12 at 17:59
0

The easiest way would be to use a Nib. Open the view's .xib file and insert a new UIView object at the bottom with the desired dimensions. Then in the Identity inspector set the class to AdWhirlView, and in the Size inspector set it so it anchors to the bottom, left and right of the screen.

benwad
  • 6,414
  • 10
  • 59
  • 93
  • Hi, Thank you for your help. I added a subview of size 320 x50 and co-ordinates 0, 410 to the AdWhirl_ProViewContoller.xib and I set the class to AdWhirlView. But the view is blank and the adVIew is still at the top of the screen. Am I still doing something wrong? Thank you again for your help. Have a good weekend. – theMouse Mar 17 '12 at 02:03
  • Have you linked it up to the code? You need to add an AdWhirlView to the class definition in AdWhirl_ProViewController.h and specify it as an `IBOutlet` to make it visible to Interface Builder, then in the Nib file click on "File's owner", go to the Connections panel (on the right) and drag a link from your new AdWhirlView variable to the element in the Nib. I hope I explained that clearly, ask me if there's anything I need to clarify! – benwad Mar 19 '12 at 09:32
  • Hi, Thank you very, very much for your help! Sorry to be a pain but the simulator shows a blank view at the bottom of the screen but the adView is still on the top of the screen so I am still doing something wrong. I have: added an AdWhirlView to the class definition in AdWhirl_ProViewController.h made it into an IBOutlet in the NIB file, connected the file's owner to the UIView the adPosition UIView is set to class = AdWhirlView – theMouse Mar 20 '12 at 19:26
  • This is what the AdWhirl_proViewController.h looks like: ` #import #import "AdWhirlDelegateProtocol.h" #import "AdWhirlView.h" @class AdWhirlView; @interface AdWhirl_proViewController : UIViewController { BOOL configFetched; AdWhirlView *adView; IBOutlet UIView* AdPosition; } @property(nonatomic,retain)AdWhirlView *adView; @property(nonatomic,retain)UIView*AdPosition; @end` – theMouse Mar 20 '12 at 19:29
  • You'll need to make the AdWhirlView an IBOutlet - you don't need to make it a UIView in the interface. Something like this (for the bit underneath the \@interface line): `{ BOOL configFetched; AdWhirlView *adView; } @property (nonatomic, retain) IBOutlet AdWhirlView *adView; @end` – benwad Mar 21 '12 at 10:24
  • Then make the UIView you put into the Nib an instance of the AdWhirlView class (in the Identity inspector tab on the right-hand side) and connect them up. Then in the view controller specify `self.adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self];` – benwad Mar 21 '12 at 10:27
  • Thanks for the reply, I now have: @interface AdWhirl_proViewController : UIViewController { BOOL configFetched; AdWhirlView *adView; } @property(nonatomic,retain) IBOutlet AdWhirlView *adView; and added UIView to the nib file set to AdWhirlView Class and connected it to IBOutlet AdView – theMouse Mar 23 '12 at 18:28
  • And added to the viewDidLoad Stub: self.adWhirlView = [AdWhirlView requestAdWhirlViewWithDelegate:self]; But I get this error: AdWhirl_proViewController.m:74: error: request for member 'adWhirlView' in something not a structure or union Thank you for your help, have a good weekend – theMouse Mar 23 '12 at 18:40
  • Do you have the line `@synthesize adView` at the top of your implementation? – benwad Mar 26 '12 at 08:55
  • Thank you for replying, yes, in the .m file, I have: #import "AdWhirl_proViewController.h" #import "AdWhirl_proAppDelegate.h" #import "AdWhirlView.h" #define kSamplaAppKey @"2e8d7eed0b1b102d96dc5b26aef5c1"; [att]implementation AdWhirl_proViewController @synthesize adView; – theMouse Mar 28 '12 at 11:59