整个应用程序中的广告 iPhone 问题

发布于 2024-08-28 11:56:42 字数 398 浏览 3 评论 0原文

我将 mobclix 与 admob 一起使用。代码太大,无法将其添加到所有类中。 所以我创建了一个新类:广告

每次我想要在视图中显示广告时,我都必须将视图发送到广告类:

- (void)initAd:(UIView *) pView {
NSLog(@"ads init");
self.loadedView = pView;
.....

要在类中创建广告:

    Ad* ad = [Ads new];
    [ad initAd:self.view];

我不知道这是否是正确的方法。 每次更改视图(或类)时,我都必须创建一个新的广告对象。 有没有办法让广告实例始终运行,或者还有其他更好的方法?

多谢!!

I am using mobclix together with admob. The code is to big to add it in all classes.
So i created a new class: Ads

Everytime i want an ad in a view, i have to send the view to the ad class:

- (void)initAd:(UIView *) pView {
NSLog(@"ads init");
self.loadedView = pView;
.....

To create an ad in a class:

    Ad* ad = [Ads new];
    [ad initAd:self.view];

I dont know if thats the right way.
I have to create a new Ads object everytime i change a view (or class).
Is there a way to always have an Ads instance running, or is there another better way?

Thanks alot!!

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

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

发布评论

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

评论(1

北凤男飞 2024-09-04 11:56:42

您可能想使用单例模式。

例如:
我的 Objective-C 单例应该是什么样子?

You probably want to use the Singleton pattern.

For example:
What should my Objective-C singleton look like?

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