2014-10-27 34 views
0

我有以下情況,我想在Autolay中設置一個按鈕爲隱藏狀態。如何確保viewWillLayoutSubviews/All View Calls已完成?

所以基本上說這個方法叫做- (void) hideSomeButton。我稱這種方法爲:

BlahViewController *bVC = [[UIStoryboard storyboardWithName:"Blah"] instantiateInitialViewController]; 
[self.navigationController pushViewController:bVC animated:YES]; 
[bVC hideSomeButton]; 

我假定這是方法調用應該是什麼:

1. init Method 
2. viewDidLoad 
3. viewWillAppear 
4. viewWillLayoutSubviews (This has an explicit call making someButton.hidden = NO) 
5. viewDidLayoutSubviews 
6. hideSomeButton (This has an explicit call making someButton.hidden = NO) 

然而,`viewWillLayoutSubviews'被調用了兩次。因此,發生的情況是:

1. viewWillLayoutSubviews - Button Shown 
2. hideSomeButton - Button Hidden 
3. viewWillLayoutSubviews - Button Shown 

BOOM!沒有隱藏的按鈕!請幫忙。

回答

0

爲什麼在調用[super viewWillLayoutSubviews]而不是在bVC上調用它之後,在BlahViewController裏面的viewWillLayoutSubviews中調用hideSomeButton?

相關問題