- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UITabBarController
,它承载 5 个 UINavigationControllers
(我们称它们为 N1 - N5)。每个 UINavigationControllers
都有导致 UITableViewController 被推送到导航堆栈的 UI 元素(我使用 MonoTouch.Dialog
DialogViewController
来实现这些 UITableViewControllers
)。我们称它们为 T1 - T5。
当我在选项卡之间导航时,ViewDidAppear
方法按预期在 N1 - N5 中的每一个上被调用。但是当我触摸一个 UI 元素时,比如 N1,这会导致 T1 被推送到导航堆栈,然后尝试使用后退按钮返回,N1 的 ViewDidAppear
方法不会被调用.
有趣的是,如果我“切换”到另一个选项卡(比如 N2),然后“切换回”到 N1,ViewDidAppear
将被正常调用。即使我将 T1 插入导航堆栈,如果我进行相同的 Tab 操作,N1 的 ViewDidAppear
仍将被调用。
N1 的 MonoTouch
代码如下所示:
public class CalendarPage : UINavigationController
{
private DialogViewController dvc;
public override void ViewDidAppear (bool animated)
{
// initialize controls
var now = DateTime.Today;
var root = new RootElement("Calendar")
{
from it in App.ViewModel.Items
where it.Due != null && it.Due >= now
orderby it.Due ascending
group it by it.Due into g
select new Section (((DateTime) g.Key).ToString("d"))
{
from hs in g
select (Element) new StringElement (((DateTime) hs.Due).ToString("d"),
delegate
{
ItemPage itemPage = new ItemPage(this, hs);
itemPage.PushViewController();
})
{
Value = hs.Name
}
}
};
if (dvc == null)
{
// create and push the dialog view onto the nav stack
dvc = new DialogViewController(UITableViewStyle.Plain, root);
dvc.NavigationItem.HidesBackButton = true;
dvc.Title = NSBundle.MainBundle.LocalizedString ("Calendar", "Calendar");
this.PushViewController(dvc, false);
}
else
{
// refresh the dialog view controller with the new root
var oldroot = dvc.Root;
dvc.Root = root;
oldroot.Dispose();
dvc.ReloadData();
}
base.ViewDidAppear (animated);
}
}
最佳答案
我明白了这是怎么回事。当在内部 DialogViewController
(在 ItemPage 中创建)上按下后退按钮时,外部 DialogViewController
(上面的“T1”)现在是第一响应者,而不是 UINavigationController
(“N1”)。我的困惑源于我关闭了那个外部 DialogViewController
上的后退按钮,所以我假设我一直弹出到 UINavigationController
(N1),而我还在 DialogViewController
(T1) 中。
我通过在内部 DialogViewController
(本例中为 ItemPage)上创建一个 ViewDissapearing
事件并检查我是否实现了所需的行为(刷新“T1”的内容)弹出 - 如果是,则调用父 Controller 的 ViewDidAppear
方法。
actionsViewController.ViewDissapearing += (sender, e) =>
{
if (actionsViewController.IsMovingFromParentViewController)
controller.ViewDidAppear(false);
};
请注意这段代码的有趣之处在于实际起作用的属性是 IsMovingFromParentViewController
,而不是 IsMovingToParentViewController
正在导航回来)。我想这可能是 MT.Dialog 中的一个错误,但由于后向紧凑的原因无法修复。
我希望这最终能帮助到某人...
关于ios - UINavigationController 上的 ViewDidAppear 在向后导航时未被调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10158960/
在我们的数据库表上,我们使用两个唯一的非聚集索引来创建跨四个字段的唯一约束。我们使用两个,因为其中一个字段 ZipCode 是一个可为空的字段。如果表中存在一条包含 ZipCode 的 null 条目
我刚刚开始学习 Rails 3 教程,以便对框架有一点熟悉,但我在生成 schema.rb 时遇到了问题。我的操作系统是 Windows 7 x64、Ruby 1.9.2、MySQL2 gem 0.2
我是一名优秀的程序员,十分优秀!