MonoTouch: Loading screen

感情迁移 提交于 2019-12-12 02:13:11

问题


I have a loading screen for my app (default.png).

When user suspends my app, I thought that iOS would automatically take a screenshot and use it as a loading screen when my app is resumed?

If I implement this... http://pastebin.com/P0w9GJrB ... won't I overwrite my loadingscreen? I mean if I have a lotta stuff on my view, the user presses homebutton and my app goes to the background. I save the screenshot. Now the user terminates my app. Next time he run my app, won't he load the saved screenshot instead of my original loading image? Reason I'm asking is, that if user forces my app to terminate, then he should see a clean loading screen when starting up my app instead of a messy saved screenshot?

Thanks all.

Mojo


回答1:


You should not be able to write over your applications files, including Default.png, since it's part of the application bundle. Doing so would invalidate the digital signature of the bundle and iOS would not launch it (unless you have a rooted device).

You can likely hack around this by not using Default.png but your own file, e.g. stored inside the Document directory where you have write access, but it will be shown later (and by your own code, like you already have in your pastebin) than what can be done by iOS when it launch your application.

Even so it can be worth it... it all depends on how much time your application takes to load.




回答2:


#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

Call the ShowSplash() method from Appdelegate Class of FinishedLaunching Method



来源:https://stackoverflow.com/questions/8287860/monotouch-loading-screen

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!