2011-11-27 162 views
0

我有一個加載屏幕爲我的應用程序(default.png)。MonoTouch:加載屏幕

當用戶暫停我的應用程序時,我認爲iOS會自動截取屏幕截圖並在恢復應用程序時將其用作加載屏幕?

如果我實現這個... http://pastebin.com/P0w9GJrB ......不會我覆蓋我的loadingscreen?我的意思是,如果我在我的視圖中有很多東西,用戶將按住home按鈕,我的應用程序會轉到後臺。我保存截圖。現在用戶終止我的應用程序。下一次他運行我的應用程序,他不會加載保存的屏幕截圖,而不是我的原始加載圖像?我問的原因是,如果用戶強制我的應用程序終止,那麼他應該在啓動我的應用程序時看到一個乾淨的加載屏幕,而不是一個雜亂的保存的屏幕截圖?

謝謝大家。

回答

0

你不應該能夠寫在你的應用程序文件,包括爲Default.png,因爲它是應用程序包的一部分。這樣做會使捆綁軟件的數字簽名失效,iOS不會啓動它(除非您擁有固定的設備)。

你可能會通過不使用Default.png來破解這個問題,但你自己的文件存儲在您有寫入權限的Document目錄中,但稍後會顯示(通過您自己的代碼,就像您在Pastebin中已有的代碼一樣),而不是iOS啓動應用程序時可以執行的操作。

即便這樣也值得...這一切都取決於您的應用程序需要多長時間加載。

+0

謝謝 - 你在這裏是一個很大的幫助! :) – MojoDK

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()方法

+0

thankx是的,它爲我的問題工作解決 – 2012-11-22 10:26:11