Ios 从Xamarin窗体导航到Xamarin本机

Ios 从Xamarin窗体导航到Xamarin本机,ios,xamarin,xamarin.ios,xamarin.android,Ios,Xamarin,Xamarin.ios,Xamarin.android,我的问题是,我要求我的应用程序的第一页是本地的。当用户注销时,我需要一种从Xamarin表单内容页面导航到应用程序的第一个本机页面的方法。是否存在从表单页面启动本机ViewController(iOS)或启动活动(Android)的任何错误。我经常使用自定义渲染器 如果我能以某种方式重新启动应用程序或再次调用AppDelegate之类的东西,那就太棒了 非常感谢您的帮助。如果您定期使用自定义渲染器,那么您可以创建自定义视图渲染器,如。例如: 在PCL中: public class NewView

我的问题是,我要求我的应用程序的第一页是本地的。当用户注销时,我需要一种从Xamarin表单内容页面导航到应用程序的第一个本机页面的方法。是否存在从表单页面启动本机ViewController(iOS)或启动活动(Android)的任何错误。我经常使用自定义渲染器

如果我能以某种方式重新启动应用程序或再次调用AppDelegate之类的东西,那就太棒了


非常感谢您的帮助。

如果您定期使用自定义渲染器,那么您可以创建自定义视图渲染器,如。例如:

在PCL中:

public class NewView : View
{
}
在Android平台中,首先在/Resources/layout下创建一个布局,如下所示:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">
  <TextView android:id="@+id/tv"
            android:layout_height="wrap_content"
            android:layout_width="match_parent"
            android:text="this is new view." />
  <Button android:id="@+id/btn"
          android:layout_height="wrap_content"
          android:layout_width="match_parent"
          android:text="change text" />
</LinearLayout>
public class NewViewRenderer : ViewRenderer
{
    private TextView tv;
    private Android.Widget.Button btn;

    protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.View> e)
    {
        base.OnElementChanged(e);
        if (Control == null)
        {
            var context = Xamarin.Forms.Forms.Context;
            LayoutInflater minflater = context.GetSystemService(Context.LayoutInflaterService) as LayoutInflater;
            var view = minflater.Inflate(Resource.Layout.newview, this, false);
            tv = view.FindViewById<TextView>(Resource.Id.tv);
            btn = view.FindViewById<Android.Widget.Button>(Resource.Id.btn);
            SetNativeControl(view);
        }

        if (e.OldElement != null)
        {
            btn.Click -= Btn_Click;
        }

        if (e.NewElement != null)
        {
            btn.Click += Btn_Click;
        }
    }

    private void Btn_Click(object sender, EventArgs e)
    {
        tv.Text = "Text changed!";
    }
}
最后,在
ContentPage
中使用此视图,使其看起来像一个页面:

<ContentPage.Content>
    <local:NewView />
</ContentPage.Content>

对于iOS平台,应该有一种方法将
ViewController
设置为视图渲染器的本机控件。但我不熟悉iOS,你可以试试