我们想要找到 View 堆栈中最顶层的 ViewController 来呈现一个小弹出窗口。 为此,我们找到关键窗口 rootviewcontroller 的 NavigationController:
var root = UIApplication.SharedApplication.KeyWindow.RootViewController.NavigationController;
var ctrl = rootNav.TopViewController as ViewControllerBase; // our own VC
return ctrl != null ? ctrl.Popup : null;
这在 Debug模式下有效 - 在 Release模式下“RootViewController”为空? MVX 是否为此提供了不同的解决方案?我们如何访问 UINavigationController?
最佳答案
调试到发布的差异向我表明这是 Xamarin.iOS/MonoTouch 效果 - 可能与链接器设置有关。
可能值得追查这个问题是什么并尝试解决它。
但是,如果您确实想要快速修复 - 如果您想使用 MvvmCross 存储的对 RootViewController 的引用,那么您可以在继承自 MvxTouchViewPresenter
的自定义 Presenter 中执行此操作 - 请参阅 MvxTouchViewPresenter.cs#L158
关于ios - 如何使用 Mvvmcross 访问 Xamarin iOS 中的大多数顶部 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17656665/