Interface Builder 中的 Objective-C、Adwhirl 横幅

发布于 2024-11-12 17:11:40 字数 349 浏览 4 评论 0原文

有人对如何在界面生成器中制作 AdWhirl 横幅有任何建议吗?现在我使用这段代码来制作一个横幅:

 AdWhirlView *awView = [AdWhirlView requestAdWhirlViewWithDelegate:self]; 

[self.view addSubview:awView];

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

我尝试制作一个 UIView 并为其制作一个 IBOutlet 并使其成为 AdWhirlView 类,但我似乎无法正确执行...

谢谢

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

一腔孤↑勇 2024-11-19 17:11:40

这是我与 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;
}

然后

 awView = [AdWhirlView requestAdWhirlViewWithDelegate:self];

使用大小为 320x50 的类 AdWhirlView 将 awView 连接到 IB 中的 UIView

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

拥醉 2024-11-19 17:11:40

我记得我在一个类似的项目中使用了 ADWhirl。我只是在这里复制代码

- (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];
}

然后不要忘记实现这些委托方法。

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

- (UIViewController *)viewControllerForPresentingModalView {
    return self;
}

最后,还实现这些委托方法以便更好地调试。

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

更新:

我在使用 IB 的视图后收到广告。

在此处输入图像描述

但它仅以编程方式获取 adView 的矩形。我的意思是,我将 adView 放在 IB 的中间,但它过去显示在顶部。但是,是的,我收到了广告。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文