【问题标题】:MonoTouch: Loading screenMonoTouch:载入画面
【发布时间】:2011-11-27 18:21:45
【问题描述】:

我的应用有一个加载屏幕 (default.png)。

当用户暂停我的应用时,我以为 iOS 会在我的应用恢复时自动截取屏幕并将其用作加载屏幕?

如果我实现这个... http://pastebin.com/P0w9GJrB ...我不会覆盖我的加载屏幕吗?我的意思是,如果我的视图上有很多东西,用户按下主页按钮,我的应用程序就会进入后台。我保存截图。现在用户终止了我的应用程序。下次他运行我的应用程序时,他不会加载保存的屏幕截图而不是我的原始加载图像吗?我要问的原因是,如果用户强制我的应用程序终止,那么他应该在启动我的应用程序时看到一个干净的加载屏幕,而不是一个杂乱的保存屏幕截图?

谢谢大家。

魔力

【问题讨论】:

    标签: c# iphone ios xamarin.ios splash-screen


    【解决方案1】:
    #region Splash Screen
    public  void  ShowSplash(){
    // get the Height & Width of device Screen
    float mainSrcWidth = this.View.Bounds.Width;
    float mainSrcHeight = this.View.Bounds.Height;
    splashScreen = new UIImageView (UIImage.FromFile ("Images/Default.png"));
    splashScreen.Frame = new RectangleF (0, 0, mainSrcWidth, mainSrcHeight);
    //Start the thread;
    ThreadPool.QueueUserWorkItem (delegate {
    Load ();
    }
    }
    this.View.AddSubview(splashScreen);
    }
    #endregion
    
    #region Load() splashscreen
    private void Load ()
    //Sleep for 3 seconds to simulate a long load.
    Thread.Sleep (new TimeSpan (0, 0, 0, 3));
    this.BeginInvokeOnMainThread (delegate {
    splashScreen.RemoveFromSuperview ();
    splashScreen = null;
    });
    }
    #endregion
    

    从 FinishedLaunching 方法的 Appdelegate 类调用 ShowSplash() 方法

    【讨论】:

      【解决方案2】:

      您应该无法覆盖您的应用程序文件,包括 Default.png,因为它是应用程序包的一部分。这样做会使捆绑包的数字签名无效,并且 iOS 不会启动它(除非您有根设备)。

      您可以通过不使用 Default.png 而是使用您自己的文件来解决此问题,例如存储在您具有写入权限的 Document 目录中,但稍后会显示(通过您自己的代码,就像您在 pastebin 中已有的一样),而不是 iOS 在启动应用程序时可以执行的操作。

      即便如此,这也是值得的……这完全取决于您的应用程序需要多少时间来加载。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-03-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-24
        • 1970-01-01
        相关资源
        最近更新 更多