2017-03-16 47 views
1

我刚注意到使用interactivePopGestureRecognizer返回到我的应用时出现了一个奇怪的行为。Monotouch interactivePopGestureRecognizer和Navigation.popasync()空白视图

情景:

1)用户从左至右,他又回到一个视图“interactivePopGestureRecognizer”视DS把。 2)用户向上或向下滑动“等待Navigation.PopAsync(false);”被调用并且用户返回一个视图。 3)如果用户执行动作“1”,然后调用新视图并尝试使用动作2返回,则显示空白视图。

此错误仅在用户使用操作1并尝试使用操作2时才会显示;应用程序工作正常,如果行动1从未使用或只使用行动1,没有两个。

我正在使用Xamarin.Forms,我尝试使用“interactivePopGestureRecognizer.enabled = false”,但每次尝试都会收到错误。两个后面的导航是否有区别?

------------- UPDATE ----------

读了很多,看在互联网后,我发现了〜interactivePopGestureRecognizer.enabled =如果你在〜ViewWillAppear中使用它,false只会有效。我创建了一个自定义的渲染器,将它应用到我的应用中的每个tableView。我仍然想弄清楚为什么背面滑动以这种方式行事。

----更新2 --- 只需按下后退按钮,然后尝试调用navigation.popasync也给我一个空白页面。这似乎是Xamarin.Navigation和iOS后退功能之间的错误。

页:

MessagingCenter.Subscribe<string>(this, "UpSwipe", async (sender) => 
     { 
      try 
      { 

       //await Navigation.PopAsync(false); 
       Navigation.RemovePage(this); 
      } 
      catch (Exception e) 
      { 
       await DisplayAlert("IsLoading", e.ToString(), "OK"); 
      } 


     }); 

     MessagingCenter.Subscribe<string>(this, "DownSwipe", async (sender) => 
     { 
      try 
      { 
       //await Navigation.PopAsync(false); 
       Navigation.RemovePage(this); 
      } 
      catch (Exception e) 
      { 
       await DisplayAlert("IsLoading", e.ToString(), "OK"); 
      } 
     }); 

渲染:

private void UpdateUp() 
    { 
     // Insert view of DetailLeft element into subview 
     // Add button to open Detail to parent navbar, if not yet there 
     // Add gesture recognizer for left swipe 
     //Console.WriteLine ("Left swipe"); 
     if (!buttons[2].Selected && !buttons[1].Selected) 
     { 

      MessagingCenter.Send("Swiped Up", "UpSwipe"); 

     } 

    } 

    private void UpdateDown() 
    { 
     // Insert view of DetailLeft element into subview 
     // Add button to open Detail to parent navbar, if not yet there 
     // Add gesture recognizer for left swipe 
     //Console.WriteLine ("Left swipe"); 
     if (!buttons[2].Selected && !buttons[1].Selected) 
     { 
      MessagingCenter.Send("Swiped Down", "DownSwipe"); 
     } 

    } 

回答

0

调试后几个小时我加入我的渲染器内return语句固定我的问题。我正在检查并在渲染器中添加一些gestureRecognizers,因此直到此错误出现时才需要返回。

protected override void OnElementChanged (ElementChangedEventArgs<LRMasterDetailPage> e) 
    { 
     base.OnElementChanged (e); 

     if (e.OldElement != null) 
     { 
      return; 
     } 
}