Xamarin.Forms中导航堆栈中的错误删除

时间:2017-04-28 15:21:39

标签: xamarin navigation xamarin.forms stack

我对Xamarin.Forms及其Navigation Pages系统有一个简单但有点疯狂的问题。 我的应用程序就像这样开始:

public static void lsdRadixSort(int[] a)
{
    final int BITS = 32; // each int is 32 bits 
    final int R = 1 << BITS_PER_BYTE; // each bytes is between 0 and 255
    final int MASK = R - 1; // 0xFF
    final int w = BITS / BITS_PER_BYTE;  // each int is 4 bytes

    int n = a.length;
    int[] aux = new int[n];

    for(int d = 0; d < w; d++)
    {
        // compute frequency counts
        int[] count = new int[R+1];

        for(int i = 0; i < n; i++)
        {           
            int c = (a[i] >> BITS_PER_BYTE*d) & MASK;
            count[c + 1]++;
        }

        // compute cumulates
        for(int r = 0; r < R; r++)
        {
            count[r+1] += count[r];
        }

        //for most significant byte, 0x80-0xFF comes before 0x00-0x7F
        if(d == (w - 1))
        {
            int shift1 = count[R] - count[R/2];
            int shift2 = count[R/2];

            for(int r = 0; r < R/2; r++)
            {
                count[r] += shift1;
            }

            for(int r = (R/2); r < R; r++)
            {
                count[r] -= shift2;
            }
        }

        // move data
        for(int i = 0; i < n; i++)
        {
            int c = (a[i] >> BITS_PER_BYTE*d) & MASK;
            aux[count[c]++] = a[i];
        }

        // copy back
        for(int i = 0; i < n; i++)
        {
            a[i] = aux[i];
        }
    }
}

所以,我有我的NavigationPage。现在,我做了一些操作,我的导航堆栈(从上到下)是这样的:

MainPage = new NavigationPage(new IntroPage());

现在,我想这样做。 从此堆栈中删除:角色,注册和详细信息页面。 之后,转到新的DetailsPage会出现这样的情况:

NewPersonPage (Page where I am now)
------
RolePage
------
RegisterPage
------
DetailsPage
------
HomePage
------
IntroPage

要做到这一点,在NewPersonPage中我这样做:

DetailsPage (new, and where I am now)
------
NewPersonPage
------
HomePage
------
IntroPage

目前还没有问题。 现在,从我的新DetailsPage,我想从我的堆栈中删除NewPersonPage。所以我这样做:

// Remove RolePage
Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
// Remove RegisterPage
Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);
// Remove DetailsPage
Navigation.RemovePage(Navigation.NavigationStack[Navigation.NavigationStack.Count - 2]);

// Now create new DetailsPage and go here
await Navigation.PushAsync(new DetailsPage(stuff));

但它不起作用!抛出一个例外,说我超出了我的筹码范围。但事实并非如此,因为如果我尝试继续前一页,我就会这样做,然后继续使用NewPersonPage。 为什么不能正常工作?

0 个答案:

没有答案