c# - OnDisappearing 和 OnAppearing 覆盖不能被视为页面导航的保证指示? Xamarin.Forms

标签 c# android ios xamarin xamarin.forms

我正在向 Xamarin.Forms 应用程序添加导航。每次离开页面时,我都需要执行一个方法。我想覆盖 OnDisappearing来自 Page 的方法基类。问题是在在线 Xamarin 书中,在 navigation chapter 上我找到了这个声明:

Calls to the OnDisappearing and OnAppearing overrides cannot be treated as guaranteed indications of page navigation. For example, on iOS, the OnDisappearing override is called on the active page when the application terminates.

这是否意味着当导航到另一个页面时,OnDesappeating 方法不会每次都正确执行?

最佳答案

这些方法在 iOS 和 Android 的不同地方被提出。因此,例如,OnAppearing 将在 PageRenderer 中的 OnAttachedToWindow 中调用。在 Android 中,OnAttachedToWindow 与“导航到页面”的含义不同;有时它的调用时间比预期的要早。例如,TabLayout 将预初始化当前选项卡附近的选项卡,并为所有这些选项卡调用 OnAttachedToWindow。

关于c# - OnDisappearing 和 OnAppearing 覆盖不能被视为页面导航的保证指示? Xamarin.Forms,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41207393/

相关文章:

c# - NUnit 无法构建测试 - 未发现测试

ios - 用 Throttle 替换所有 UIButton 触摸事件

ios - 为什么我的 UIView 动画到错误的位置?

ios - 我的共享扩展未显示在保管箱扩展中

c# - 从列表中选择到多个列表

c# - 异步回发不起作用

android - cstdlib 的 NDK 错误

使用占位符和进度条加载 Android 查询图像

android - Android widget 的 updatePeriodMillis 的最大值是多少?

C# UDP 发送缓冲区