iOS5中新的应用风格,你必须在UIWindow上设置RootViewController,这让我很困惑。
我从这里下载了最新的 MonoTouch.Dialog 库:
https://github.com/migueldeicaza/MonoTouch.Dialog
但是当我尝试在模拟器上编译和运行包含的“示例”项目时,它崩溃并返回以下错误:
错误:应用程序在应用程序启动结束时应该有一个根视图控制器
然后我在 GitHub 上打开了一个问题:
https://github.com/migueldeicaza/MonoTouch.Dialog/issues/65
但米格尔回答我说:
如果你使用iOS5新风格的应用程序,你必须在UIWindow上设置RootViewController。这是一个新的 iOS 5 功能部分,用于将 UIViewController 包含到位。
我试图将示例应用程序的导航控制器分配给窗口根视图控制器,但没有任何效果。仍然得到同样的错误。这是包含的示例应用程序的 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;
}
我添加的唯一代码行是注释中指出的那一行,但是这个添加似乎并没有解决错误。有什么我想念的吗?
提前致谢!