iPhone 中的 iAd 在未加载时会显示动画

发布于 2024-09-26 14:13:58 字数 1647 浏览 1 评论 0原文

我在屏幕底部添加了用于实施 iAd 的横幅视图。但是,当在模拟器上运行时,横幅视图略高于为其固定的框架。它显示为透明条且不可选择。一段时间后,它会自动到达底部,显示一条黑色条带,上面写着“测试广告”。

我希望横幅视图粘在底部而不是动画。

这是我的代码。 adView 声明代码:

adView = [[[ADBannerView alloc] initWithFrame:CGRectOffset(CGRectZero, 0, 350)] autorelease];
adView.frame = CGRectMake(0,340,320,25);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;
adView.tag = 111;
[self.navigationController.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
adView.hidden = YES;

以下是委托方法。

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)  {

        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];

        // banner is invisible now and moved out of the screen on 50 px
        banner.frame = CGRectOffset(banner.frame, 0, 50);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

// When iAd is not availale on the banner
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible) {

        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];        
        // banner is visible and we move it out of the screen, due to connection issue
        banner.frame = CGRectOffset(banner.frame, 0, 520);
        [UIView commitAnimations];      
        self.bannerIsVisible = NO;
    }
}

我无法理解这个问题。请帮忙。

I have added a banner view for implementing iAd in the bottom of the screen. But when running on the simulator the banner view is slightly above the frame fixed for it. It appears as a transparent strip and is not selectable. After sometime it automatically comes to the bottom as a black strip saying Test Advertisement.

I want the banner View to stick to the bottom and not animate.

Here is my code. The adView declaration code:

adView = [[[ADBannerView alloc] initWithFrame:CGRectOffset(CGRectZero, 0, 350)] autorelease];
adView.frame = CGRectMake(0,340,320,25);
adView.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
adView.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
adView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin;
adView.tag = 111;
[self.navigationController.view addSubview:adView];
adView.delegate = self;
self.bannerIsVisible = NO;
adView.hidden = YES;

Here are the delegate methods.

- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
    if (!self.bannerIsVisible)  {

        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];

        // banner is invisible now and moved out of the screen on 50 px
        banner.frame = CGRectOffset(banner.frame, 0, 50);
        [UIView commitAnimations];
        self.bannerIsVisible = YES;
    }
}

// When iAd is not availale on the banner
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
    if (self.bannerIsVisible) {

        [UIView beginAnimations:@"animateAdBannerOff" context:NULL];        
        // banner is visible and we move it out of the screen, due to connection issue
        banner.frame = CGRectOffset(banner.frame, 0, 520);
        [UIView commitAnimations];      
        self.bannerIsVisible = NO;
    }
}

I am not able to understand the problem. Kindly help.

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

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

发布评论

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

评论(1

待"谢繁草 2024-10-03 14:13:58

首先。
当主视图加载时,对象最初是如何放置在其中的?我总是将它们放置在 viewDidLoad 方法中的正确位置。因此,将横幅放在主视图底部下方,确保

myBannerFrame.origin.x = 0;
myBannerFrame.origin.y = mainView.frame.size.height;
[myBanner setFrame:myBannerFrame]; // no need for animation here! 

viewDidLoad 是将标记 self.bannerIsVisible 设置为 FALSE 的好地方。

第二。不要使用像这里这样的固定像素值,

banner.frame = CGRectOffset(banner.frame, 0, 50);

而不是50,你最好使用banner.frame.size.height
这将帮助您避免许多错误和错位。

First.
When the main view is loaded how are the objects placed in it initially? I always place them in right positions inside viewDidLoad method. So place your banner below the bottom of the main view making sure that

myBannerFrame.origin.x = 0;
myBannerFrame.origin.y = mainView.frame.size.height;
[myBanner setFrame:myBannerFrame]; // no need for animation here! 

Also viewDidLoad is a good place to set your flag self.bannerIsVisible to FALSE.

Second. Do not use fixed pixel values like here

banner.frame = CGRectOffset(banner.frame, 0, 50);

instead of 50 you better put banner.frame.size.height
This will help you to avoid many errors and misalignments.

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