The new style of applications in iOS5, where you must set the RootViewController on the UIWindow, is getting me very confused.
I've downloaded the latest MonoTouch.Dialog library from here:
https://github.com/migueldeicaza/MonoTouch.Dialog
But when I tried to compile and run the included "Sample" project on the Simulator, it crashes and returns the following error:
Error: Applications are expected to have a root view controller at the end of application launch
I then opened an issue on GitHub:
https://github.com/migueldeicaza/MonoTouch.Dialog/issues/65
But Miguel answered me that:
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.
I tried to assign the Navigation controller of the Sample application to the window root view controller, but with no effect. Still getting the same error. This is the FinishedLaunching method of the included Sample application:
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;
}
The only line of code I've added is the one indicated in the comments, but this addition doesn't seem to solve the error. Is there something I'm missing?
Thanks in advance!