iOS5中的新風格的應用程序,你必須在UIWindow上設置RootViewController,這讓我非常困惑。MonoTouch和「應用程序在應用程序啓動結束時應該有一個根視圖控制器」錯誤
我從這裏下載最新的MonoTouch.Dialog庫:
https://github.com/migueldeicaza/MonoTouch.Dialog
但是,當我試圖編譯並在模擬器上運行附帶的「樣本」的項目,它崩潰並返回以下錯誤:
Error: Applications are expected to have a root view controller at the end of application launch
我再開GitHub上的問題:
https://github.com/migueldeicaza/MonoTouch.Dialog/issues/65
但米格爾回答我說:
If you use the new style of applications in iOS5, you must set the RootViewController on the UIWindow. That is a new iOS 5 feature part of the cleanup to bring UIViewController containing into place.
我試圖示例應用程序的窗口根視圖控制器的導航控制器分配,但沒有效果。仍然得到相同的錯誤。這是所包含的樣本應用程序的FinishedLaunching方法:
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
var Last = new DateTime (2010, 10, 7);
Console.WriteLine (Last);
var p = Path.GetFullPath ("background.png");
window.AddSubview (navigation.View);
//ADDING THE Navigation Controller as RootViewController
window.RootViewController = navigation; //THIS LINE WAS ADDED BY ME
var menu = new RootElement ("Demos"){
new Section ("Element API"){
new StringElement ("iPhone Settings Sample", DemoElementApi),
new StringElement ("Dynamically load data", DemoDynamic),
new StringElement ("Add/Remove demo", DemoAddRemove),
new StringElement ("Assorted cells", DemoDate),
new StyledStringElement ("Styled Elements", DemoStyled) { BackgroundUri = new Uri ("file://" + p) },
new StringElement ("Load More Sample", DemoLoadMore),
new StringElement ("Row Editing Support", DemoEditing),
new StringElement ("Advanced Editing Support", DemoAdvancedEditing),
new StringElement ("Owner Drawn Element", DemoOwnerDrawnElement),
},
new Section ("Container features"){
new StringElement ("Pull to Refresh", DemoRefresh),
new StringElement ("Headers and Footers", DemoHeadersFooters),
new StringElement ("Root Style", DemoContainerStyle),
new StringElement ("Index sample", DemoIndex),
},
new Section ("Auto-mapped", footer){
new StringElement ("Reflection API", DemoReflectionApi)
},
};
var dv = new DialogViewController (menu) {
Autorotate = true
};
navigation.PushViewController (dv, true);
window.MakeKeyAndVisible();
return true;
}
我所添加的代碼的唯一行是一個在評論中指出的,但這除了似乎並沒有解決錯誤。有什麼我失蹤?
在此先感謝!
你意味着你不能使用MT5編譯MT.D(形成GIT)並使其在iOS(5)模擬器上工作?這就是爲什麼你要添加這一行代碼? – poupou
是的。我正在嘗試使用MonoTouch 5.0編譯MonoTouch.Dialog示例項目。但是我得到了一個崩潰和那個錯誤。有沒有人試圖用MonoTouch 5.0進行編譯? –
我得到這個錯誤,以及我正在做的MonoGame項目(因爲視圖/控制器都隱藏在MonoGame中)。但是,沒有任何崩潰,我只是在控制檯上收到「警告」消息。你確定它不會在別的地方崩潰嗎? – jonathanpeppers