2012-10-03 29 views
0

我正在使用storyboards。 這是我的觀點在導航視圖中按下循環控制器

My NavigationController --> [Series of ViewControllers] ->About View Controller 

現在從AboutViewController

AboutViewController--> ViewController1-->ViewController2-->ViewController3-->ViewController4--> 

AboutViewController using PUSH SEGUE

現在假設我是一個用戶,我做以上和回來後AboutViewController我再去viewController1等高達viewController4並執行這個循環多次。

我想知道這是否會導致一些內存問題,因爲視圖被放在棧上navigationController。如果是的話應採用什麼策略回aboutViewControllerViewController4

回答

0

不,它不會產生任何內存問題。 iOS會照顧你。當它出現另一個視圖時,如果你沒有強引用週期,那麼以前的視圖會自動釋放(總是對子視圖控制器中父對象的引用很弱)。您可以嘗試在每個視圖控制器中添加如下所示的initWithCoder和dealloc方法,並查看會發生什麼情況。

- (id)initWithCoder:(NSCoder *)aDecoder 
{ 
    if ((self = [super initWithCoder:aDecoder])) 
    { 
     NSLog(@"init ViewController"); 
    } 
    return self; 
} 

- (void)dealloc 
{ 
    NSLog(@"dealloc ViewController"); 
} 

另外添加viewDidAppear - ViewDidDisappear方法來查看到底發生了什麼。這真的很有趣。讓我知道這是否沒有意義。

P.S詳情請參閱Beginning Storyboards in iOS 5教程。