Question

I am using the overlay code from here - http://docs.xamarin.com/recipes/ios/standard_controls/popovers/display_a_loading_message

It worked all fine..., I was able to call View.Add(loadingOverlay)

...until I changed things to MonoTouch.Dialog and it doesn't work anymore.

public partial class BaseView : UIViewController
{
    LoadingOverlay loadingOverlay;

    public void ProgressDialogShow(string message, string title)
    {
        loadingOverlay = new LoadingOverlay(message, UIScreen.MainScreen.Bounds);
        View.Add(loadingOverlay);
    }
}

And the View itself (the LoginView) is inheriting from BaseView.

[Register("SecondLoginView")]
public class SecondLoginView : BaseView
{
    public override void ViewDidLoad()
    {
        base.ViewDidLoad();
        window = new UIWindow(UIScreen.MainScreen.Bounds);

        root = new RootElement("Login") {
            new Section() {
            new EntryElement ("Benutzer", "Login", "Test")
            }
        };
        rootVC = new DialogViewController(root);
        nav = new UINavigationController(rootVC);
        window.RootViewController = nav;
        window.MakeKeyAndVisible();
    }
}

In that case, the Loadingoverlay is not showing up. How can I still use it with MonoTouch.Dialog?

Any help appreciated!

Was it helpful?

Solution

Slack Shot is on the right track. The reason you are having issues is because you are structuring your application strangely. You should not have the window.MakeKeyAndVisible or window.RootViewController assignments in your SecondLoginView class.

You can add your rootVC as a subview like this:

View.Add(rootVC.View);

I am sure you can do it some way with the code you have, but the way I always use a DialogViewController (if its the only view meant to be on the screen) I inherit directly from it. If you want to provide some common overlay code, make your BaseView a DialogViewController and inherit that.

Something like: 

public partial class BaseDialogController : DialogViewController
{
    LoadingOverlay loadingOverlay;

    public void ProgressDialogShow(string message, string title)
    {
        loadingOverlay = new LoadingOverlay(message, UIScreen.MainScreen.Bounds);
        View.Add(loadingOverlay);
    }
}

You should remove this code from the view controller:

    nav = new UINavigationController(rootVC);
    window.RootViewController = nav;
    window.MakeKeyAndVisible();

If you want to make your controller in a nav, do it wherever you create SecondViewController. In your case, it might be in the storyboard file.

OTHER TIPS

In your second class "secondloginview" it seems like you are trying to do things that are typically done in the app delegate file.

In that code:

What you are doing is making a navigation controller into the root view controller for the app, and then setting the login window to the only view controller attached to that Nav controller.

I think what you want to do, is remove that navigation controller code and use this.PresentviewController(RootVC,true);

To display the dialog view controller for login.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top