首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >DialogViewController不解雇ViewDidDisappear

DialogViewController不解雇ViewDidDisappear
EN

Stack Overflow用户
提问于 2012-12-08 15:49:49
回答 1查看 276关注 0票数 0

我的等级如下所示:

代码语言:javascript
复制
NavigationController
  • 在转到下一个视图时,首先推送ViewController - ViewDidDisappear正确触发
  • 推具有列表的DialogViewController - ViewDidDisappear在下一个
  • 每个列表都会打开一个新的DialogViewController - ViewDidDisappear从不文件。
  • 这里有一些按钮可以打开另一个DialogViewController - VidDidDisappear永不触发。

代码:

代码语言:javascript
复制
 public partial class CustomDialogController : DialogViewController {

    public CustomDialogController() : base (UITableViewStyle.Grouped, null, true) {
    }

    public override void ViewDidDisappear (bool animated)
    {
        base.ViewDidDisappear (animated);
        Console.WriteLine("Gone baby 2");
        // Never Fires
    }
  }

public partial class WorkoutsView : DialogViewController
{

    public override void ViewDidDisappear (bool animated)
    {
        base.ViewDidDisappear (animated);
        Console.WriteLine("Gone baby");
        // Here is where you can add your custom code for when the DialogViewController disappears
    }


    public WorkoutsView (MetaFitness.BL.MetaFitnessManager manager) : base (UITableViewStyle.Grouped, null, true)
    {
        this.Title ="Title";
        WorkoutViewModel WorkoutDetail = new WorkoutViewModel();
        //var bc = new BindingContext (this, WorkoutDetail, "Details");
        //detailView = new DialogViewController(bc.Root,true);
        List<Workout> workouts = manager.GetWorkouts ();

        var abc = new CustomDialogController();
        abc.Root = new RootElement("WorkoutsView");
        Root = abc.Root;
        Section section = new Section ("Workouts");
        foreach (var wo in workouts) {
            string name = string.Empty;

            CustomDialogController WorkoutController = new CustomDialogController();
            WorkoutController.Root = new RootElement(wo.Name);
            RootElement wSection = WorkoutController.Root;

            var s2 = new Section();
            var mvm2 = new MeasurementViewModel();
                            // the code for this is similar to CustomDialogController - never fires
            s2.Add(new MeasurementViewController(mvm2).Root);
            wSection.Add (s2);


            section.Add(wSection);  

        }
        Root.Add(section);
    }
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-08 17:55:48

这不是如何使用UINavigationControllerDialogViewController。记住UIViewController的基本概念:一个控制器处理大量内容(在iPhone上)。这意味着,您应该在UIViewController's堆栈上推送控制器。每个控制器都可以是DialogViewControllers。这么说,您已经可以看到,在MeasurementViewModel的一个部分中添加WorkoutsView的视图(根)是对上述概念的突破,因此,您违反了苹果的设计规则,结果是:您的View*()方法不会被调用。

相反:对元素添加一个回调,其中一个元素可以在导航控制器的堆栈上推送一个新的控制器。

您应该能够在MT.Dialog的Github页面:https://github.com/migueldeicaza/MonoTouch.Dialog或Xamarin博客:http://blog.xamarin.com/2012/02/10/easily-create-ios-user-interfaces-with-monotouch-dialog/上找到所有必要的文档

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13779057

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档