2014-02-26 121 views
1

我用这个简单的代码为我的UI:上缺少DateTimeElement(Monotouch.Dialog)后退按钮

challengeStartTime = new DateTimeElement("Start Time",DateTime.Now); 

Root = new RootElement ("Add Event") { 
    new Section (""){ 
     challengeStartTime 
    } 
}; 

我使用此代码了一段时间,一切都按预期。现在我将应用程序迁移到iOS 7,并出现这种奇怪的行为:1.导航到DateTimeElement 2.返回到前一个屏幕(NavigationController-Bar中有通常的后退按钮)3.再次导航到DateTimeElement(例如,如果我输入了错误的时间)4. NavigationController中没有后退按钮。没有办法导航回来。

我再次验证了我的旧版本(Appstore,“win4youth”),它在那里工作没有问题。

任何想法可能会导致这个奇怪的问题?我已经下载了当前版本https://github.com/migueldeicaza/MonoTouch.Dialog,编译并试用了它,但是行为相同。我正在为其他屏幕使用故事板,也许它与此有关?

感谢您的任何帮助

+1

检查某处您隐藏了导航控制器的后退按钮。无论是'SetHidesBackButton'还是'HidesBackButton'。 – Krumelur

回答

0

感谢@Krumelur指出正确的方向!

我有这个代码在我DialogViewController:

public override void ViewDidAppear (bool animated) 
{ 
    //this "hack" is necessary because we use a DialogViewController together with a Storyboard and have no control over the constructor 
    this.NavigationItem.HidesBackButton = false; 

    base.ViewDidAppear (animated); 
} 

这似乎是导致该问题。奇怪的是,在iOS 7之前它正在工作。一个小小的研究后,我发现这个线程:http://forums.xamarin.com/discussion/8291/navigationcontroller-missing-back-button-when-coming-from-the-third-level-to-the-second-level

这为我提供了一个解决方案:

public override void ViewWillAppear (bool animated) 
{ 
    base.ViewWillAppear (animated); 

    NavigationItem.SetHidesBackButton (false, false); 
} 

public override void ViewWillDisappear (bool animated) 
{ 
    base.ViewWillDisappear (animated); 

    NavigationItem.SetHidesBackButton (true, false); 
} 

它仍然是一个黑客,但在你的代码中的至少一个正在运行的:-)