簡體   English   中英

呈現另一個后關閉UIViewController

[英]Dismiss UIViewController after presenting another one

我正在開發一個單視圖iOS 5.0+應用程序,我將以這種方式導航拋出ViewController:

SearchViewController* search =
[[SearchViewController alloc] initWithNibName:@"SearchViewController"
                                       bundle:nil];
[self presentViewController:search
                   animated:NO
                 completion:nil];

我的問題是,如果我打開SearchViewControllerHomeViewController ,是HomeViewController解雇后SearchViewController顯示?

我有很多UIViewController ,我不知道當用戶在它們之間導航時它們是否都在內存中。

如果您只想展示一個Viewcontroller,可以嘗試一下,

 SearchViewController* search =
    [[SearchViewController alloc] initWithNibName:@"SearchViewController"
                                           bundle:nil];


    [self dismissViewControllerAnimated:NO completion:^{
        [self presentViewController:search
                           animated:NO
                         completion:nil];
    }];

當您從另一個ViewController提供一個ViewController ,它們永遠不會從內存中釋放出來。 要從內存中釋放它們,您需要明確地將其消除。

方法presentViewController:animated:completion:將presentedViewController屬性設置為指定的視圖控制器,調整該視圖控制器視圖的大小,然后將該視圖添加到視圖層次結構中。

因此,您將看到一堆ViewController,並在另一個之上添加一個View。

暫無
暫無

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

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