0
votes

I'm new to iOS app development, Xamarin/Xcode, and Monotouch.dialog. I'm trying to do the example under "More on Sections and RootElements: RootElements" (http://docs.xamarin.com/guides/ios/user_interface/monotouch.dialog/) to get myself acquainted with MonoTouch.Dialog for a multi-screen app for work. MonoTouch.Dialog seems simple, but I'm running into an inexplicable problem (q2).

So here're my questions/problems:

  1. How do I integrate a MonoTouch.Dialog created page inside a multi-screen application that uses non-table screens? Do I have to create a NavigationController inside the main NavigationController [e.g. -> (NavigationController) - Home - SomethingElse - (NavigationController) - (Monotouch.Dialog created pages)], and how do I connect the beginning page and the MonoTouch.Dialog pages?

  2. Working in Xamarin-iOS, I have done everything the example describes, and watched numerous videos, and read several Xamarin documentations of MonoTouch.dialog, but when I click the created element rows (the rows under the "Dinner" section), they do not go to the new RootElement that is behind the row. What am I doing wrong? I created a new DialogViewController project, and this is all that I've edited in the Xamarin code inside the AppDelegate.cs (Xcode storyboard only contains a NavigationController).

    UIWindow _window;
    UINavigationController _nav;
    DialogViewController _rootVC;
    RootElement _rootElement;
    
    
    public override UIWindow Window {
        get;
        set;
    }
    
    public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
    {
    
        _window = new UIWindow (UIScreen.MainScreen.Bounds);
    
    
        _rootElement = new RootElement ("Meals") {
            new Section ("Dinner") {
                (Element)new RootElement ("Dessert", new RadioGroup ("dessert", 2)) {
                        new Section () {
                            new RadioElement ("Ice Cream", "dessert"),
                            new RadioElement ("Milkshake", "dessert"),
                            new RadioElement ("Chocolate Cake", "dessert")
                        }
                },
                (Element)new RootElement ("Something"){
                    new Section () {
                        new EntryElement ("Name", "Click to edit", "")
                    }
                }
            }// end "Dinner"
        }; //end "Meals"
    
    
        _rootVC = new DialogViewController (_rootElement);
        _nav = new UINavigationController (_rootVC);
        _window.RootViewController = _nav;
        _window.MakeKeyAndVisible ();
    
        return true;
    } //end FinishedLaunching
    
1

1 Answers

0
votes

Your code works fine for me. I'm not clear where your Storyboard comes into play - there is no need for it when all of your UI is declared in the code.

You only need one NavigationController in a "stack". If your first page was just a UIViewController contained within a NavigationController with some buttons on it, you could wire up the Touch event of one of your buttons to push your MonoTouch.Dialog UI onto the stack

  protected void ButtonEvent(object sender, EventArgs e) {

    dvc = new DialogViewController(_root);

    // every view controller has a NavigationController property that will be non-null
    // if that VC is contained within a Nav Controller
    NavigationController.PushViewController(dvc,true);

  }

Likewise, from within your MonoTouch.Dialog UI you could have a StringElement whose Tapped event creates a new instance of a custom view controller class and pushes it onto the navigation stack.