簡體   English   中英

Monotouch回到第一個ViewController

[英]Monotouch back to first ViewController

我遇到問題,再次回到我的第一個Apps VC,第一個“屏幕/ ViewController)”是一個登錄屏幕,然后當我在某個級別的ViewController上時,我用各自的ViewController調用UITabbar(例如第5個)我想在我的App中獲得“注銷”行為並返回到第一個ViewController(登錄)。 但是我認為我只能導航回Tabbar控件的第一個ViewController。 我正在嘗試使用我的VC的以下方法:

this.NavigationController.PopToViewController(previousVC,true); 或this.NavigationController.PopToRootViewController(true);或

任何幫助,將不勝感激。

(如果您需要代碼的更多詳細信息,請告訴我)

    //Call to the tab bar from the login viewcontroller
    mainTBC = new TabBarMenuPpal ();
this.NavigationController.PushViewController (mainTBC, true);
…

//Tabbarmenuppal with a set of navcontrollers 
public TabBarMenuPpal ()
{
    var customerVC = new Customers ();
    navCustomers = new UINavigationController ();
    navCustomers.PushViewController (customerVC, true);
    navCustomers.TopViewController.Title = customersTitle;
    navCustomers.TabBarItem = new UITabBarItem (customersTitle, UIImage.FromFile ("Utility/Images/Cust-30x30.png"), 0);
    …
    mainVC = new UIViewController[]
    {
          navCustomers
        , navSettings
    } ;
    this.ViewControllers = mainVC;
}

問題是,當我開始在navCustomers中導航時,找不到返回登錄VC的方法(刪除我的標簽欄並釋放所有資源)。 (對不起,我的英語)。

我不知道這是否是最好的解決方案,但是我在UITabBarController中實現了一個“ GoToLogin”方法,該方法只能執行以下操作:

public void GoToLogin()
{
   this.NavigationController.PopToRootViewController(true);
}

因此,當我需要轉到第一頁時,只需執行以下操作:

if(MainDialog.NavigationController.TabBarController != null)//loaded from the tab bar
              ((TabBarMenuPpal)MainDialog.NavigationController.TabBarController).GoToLogin();
else//loaded from the login screen  
              MainDialog.NavigationController.PopToRootViewController(true);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM