问题
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
回答1:
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
回答2:
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.
来源:https://stackoverflow.com/questions/6214841/objective-c-adwhirl-banner-in-interface-builder