【问题标题】:Section with RootElement inside里面有 RootElement 的部分
【发布时间】:2014-05-02 20:53:43
【问题描述】:

我是 iOS 应用开发、Xamarin/Xcode 和 Monotouch.dialog 的新手。我正在尝试在“更多关于部分和 RootElements:RootElements”(http://docs.xamarin.com/guides/ios/user_interface/monotouch.dialog/) 下的示例,以让自己熟悉 MonoTouch.Dialog 以用于工作的多屏应用程序。 MonoTouch.Dialog 看起来很简单,但我遇到了一个莫名其妙的问题(q2)。

所以这是我的问题/问题:

  1. 如何将 MonoTouch.Dialog 创建的页面集成到使用非表格屏幕的多屏幕应用程序中?我是否必须在主 NavigationController 中创建 NavigationController [例如-> (NavigationController) - Home - SomethingElse - (NavigationController) - (Monotouch.Dialog created pages)],如何连接开始页面和 MonoTouch.Dialog 页面?

  2. 在 Xamarin-iOS 中工作,我已经完成了示例描述的所有内容,观看了许多视频,并阅读了 MonoTouch.dialog 的几个 Xamarin 文档,但是当我单击创建的元素行时(“晚餐”部分下的行) ,它们不会转到行后面的新 RootElement。我究竟做错了什么?我创建了一个新的 DialogViewController 项目,这就是我在 AppDelegate.cs 内的 Xamarin 代码中编辑的所有内容(Xcode 故事板仅包含一个 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
    

【问题讨论】:

    标签: ios xcode xamarin monotouch.dialog


    【解决方案1】:

    您的代码对我来说很好用。我不清楚你的故事板在哪里发挥作用 - 当你的所有 UI 都在代码中声明时,就不需要它了。

    “堆栈”中只需要一个NavigationController。如果您的第一页只是包含在带有一些按钮的NavigationController 中的UIViewController,您可以连接其中一个按钮的 Touch 事件以将您的 MonoTouch.Dialog UI 推入堆栈

      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);
    
      }
    

    同样,在您的 MonoTouch.Dialog UI 中,您可以拥有一个 StringElement,其 Tapped 事件创建自定义视图控制器类的新实例并将其推送到导航堆栈。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-04
      相关资源
      最近更新 更多