iPad 上的 iAd 交互搞砸了界面

发布于 2024-11-28 02:22:14 字数 200 浏览 0 评论 0原文

大家好,

我在最近的 iPad 应用程序中通过 AdWhirl 实现了 iAd,其中我需要手动调整旋转事件的界面。当我的应用程序处于横向模式并且用户点击广告时,界面将被迫旋转到纵向模式。只要应用程序被关闭就可以了,因为状态栏似乎是旋转的,但奇怪的是界面没有收到任何旋转通知,所以一切(这意味着真正的一切!)都有点搞砸了。有什么建议导致这种奇怪的行为吗? 非常感谢, 蒂姆

Hej guys,

I implemented iAd via AdWhirl in my recent iPad Application in which I need to manually adjust the interface on rotation events. When my app is in landscape and the user taps the ad the interface is forced to rotate to portrait mode. This is fine as long as the app is dismissed because the status bar seems to be rotatet but the interface strangely didn't got any notifications to rotate so everything (which means really everything!) is kinda screwed up. Any suggestions what is causing this odd behavior?
Many thanks,
Tim

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

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

发布评论

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

评论(1

终止放荡 2024-12-05 02:22:14

我遇到了完全相同的问题,我以为这可能是 MonoTouch 问题。
很高兴看看是否有人知道这是为什么。我试图强迫它旋转回来,但没有成功。

与此同时,我将发布我的应用程序,称其为已知错误。

编辑:
这是我在 MonoTouch 中使用的测试 ViewController。

using System;
using MonoTouch.iAd;
using MonoTouch.UIKit;
using MonoTouch.Foundation;


namespace ADBannerRotate
{
    public class ViewController : UIViewController
    {

        private ADBannerView adBannerView = null;

        public ViewController()
        {
        }

        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            Console.WriteLine("ViewDidLayoutSubviews");


            Console.WriteLine("ViewDidLayoutSubviews StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
            Console.WriteLine("ViewDidLayoutSubviews Orientation: " + UIDevice.CurrentDevice.Orientation);

        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Console.WriteLine("ViewDidLoad");


            adBannerView = new ADBannerView();
            adBannerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;


            NSMutableSet requiredContentSizeIdentifiers = new NSMutableSet(); 
            requiredContentSizeIdentifiers.Add(ADBannerView.SizeIdentifierPortrait);
            requiredContentSizeIdentifiers.Add(ADBannerView.SizeIdentifierLandscape); 
            adBannerView.RequiredContentSizeIdentifiers = requiredContentSizeIdentifiers;

            if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight)
            {
                adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierLandscape;
            }
            else 
            {
                adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierPortrait;
            }

            adBannerView.ActionFinished += delegate(object sender, EventArgs e) {
                Console.WriteLine("ActionFinished");

                Console.WriteLine("ActionFinished StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
                Console.WriteLine("ActionFinished Orientation: " + UIDevice.CurrentDevice.Orientation);

            };
            adBannerView.AdLoaded += delegate(object sender, EventArgs e) {
                Console.WriteLine("AdLoaded - " + adBannerView.CurrentContentSizeIdentifier);
            };
            adBannerView.FailedToReceiveAd += delegate(object sender, AdErrorEventArgs e) {
                Console.WriteLine("FailedToReceiveAd");
            };
            adBannerView.WillLoad += delegate(object sender, EventArgs e) {
                Console.WriteLine("WillLoad");
            };

            View.AddSubview(adBannerView);
        }

        public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
        {
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation - " + toInterfaceOrientation);
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation Orientation: " + UIDevice.CurrentDevice.Orientation);


            if (adBannerView != null)
            {
                if (toInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || toInterfaceOrientation == UIInterfaceOrientation.LandscapeRight)
                {
                    adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierLandscape;
                }
                else
                {
                    adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierPortrait;
                }
            }
            return true;
        }
    }
}

我遇到的一件奇怪的事情是,在 iPad(第 3 代)上 ShouldAutorotateToInterfaceOrientation 被调用 3 次,然后是 ViewDidLayoutSubviews,然后是 ActionFinished,但在 iPhone(3GS)上 ShouldAutorotateToInterfaceOrientation 被调用一次,然后 ActionFinished 被调用一次。

同样,对于 iPad,如果我将视图旋转锁定为横向,然后显示广告,然后将其关闭,它会为我将其更改为纵向。

I am getting exactly the same problem, had thought maybe it is a MonoTouch issue.
Will be good to see if anyone knows why this is. I have tried to force it to rotate back but have had no luck.

In the mean time I am just going to release my app, call it a known bug.

EDIT:
Here is a test ViewController I was using in MonoTouch.

using System;
using MonoTouch.iAd;
using MonoTouch.UIKit;
using MonoTouch.Foundation;


namespace ADBannerRotate
{
    public class ViewController : UIViewController
    {

        private ADBannerView adBannerView = null;

        public ViewController()
        {
        }

        public override void ViewDidLayoutSubviews()
        {
            base.ViewDidLayoutSubviews();
            Console.WriteLine("ViewDidLayoutSubviews");


            Console.WriteLine("ViewDidLayoutSubviews StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
            Console.WriteLine("ViewDidLayoutSubviews Orientation: " + UIDevice.CurrentDevice.Orientation);

        }

        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            Console.WriteLine("ViewDidLoad");


            adBannerView = new ADBannerView();
            adBannerView.AutoresizingMask = UIViewAutoresizing.FlexibleWidth;


            NSMutableSet requiredContentSizeIdentifiers = new NSMutableSet(); 
            requiredContentSizeIdentifiers.Add(ADBannerView.SizeIdentifierPortrait);
            requiredContentSizeIdentifiers.Add(ADBannerView.SizeIdentifierLandscape); 
            adBannerView.RequiredContentSizeIdentifiers = requiredContentSizeIdentifiers;

            if (UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeLeft || UIApplication.SharedApplication.StatusBarOrientation == UIInterfaceOrientation.LandscapeRight)
            {
                adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierLandscape;
            }
            else 
            {
                adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierPortrait;
            }

            adBannerView.ActionFinished += delegate(object sender, EventArgs e) {
                Console.WriteLine("ActionFinished");

                Console.WriteLine("ActionFinished StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
                Console.WriteLine("ActionFinished Orientation: " + UIDevice.CurrentDevice.Orientation);

            };
            adBannerView.AdLoaded += delegate(object sender, EventArgs e) {
                Console.WriteLine("AdLoaded - " + adBannerView.CurrentContentSizeIdentifier);
            };
            adBannerView.FailedToReceiveAd += delegate(object sender, AdErrorEventArgs e) {
                Console.WriteLine("FailedToReceiveAd");
            };
            adBannerView.WillLoad += delegate(object sender, EventArgs e) {
                Console.WriteLine("WillLoad");
            };

            View.AddSubview(adBannerView);
        }

        public override bool ShouldAutorotateToInterfaceOrientation(UIInterfaceOrientation toInterfaceOrientation)
        {
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation - " + toInterfaceOrientation);
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation StatusBarOrientation: " + UIApplication.SharedApplication.StatusBarOrientation);
            Console.WriteLine("ShouldAutorotateToInterfaceOrientation Orientation: " + UIDevice.CurrentDevice.Orientation);


            if (adBannerView != null)
            {
                if (toInterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || toInterfaceOrientation == UIInterfaceOrientation.LandscapeRight)
                {
                    adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierLandscape;
                }
                else
                {
                    adBannerView.CurrentContentSizeIdentifier = ADBannerView.SizeIdentifierPortrait;
                }
            }
            return true;
        }
    }
}

One funky thing I did come across is that on the iPad (3rd Gen) the ShouldAutorotateToInterfaceOrientation gets called 3 times, then ViewDidLayoutSubviews, then ActionFinished but on the iPhone (3GS) ShouldAutorotateToInterfaceOrientation gets called once, and then ActionFinished gets called once.

Also with the iPad if I lock the view rotation in landscape then bring up the ad then dismiss it, it changes it to portrait for me.

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