2010-12-02 42 views
1

你好 我遇到了一些與此有關的疑惑;我只想在視圖出現後執行一些操作,可能會在收集數據時顯示活動指示器。 我已經在viewWillAppear中編寫了我的代碼,但它似乎在視圖出現在屏幕上之前正在觸發。 我已經用一些NSLog語句檢查了這一點,並且我在viewWillAppear中添加了2秒的睡眠時間,NSLog語句被觸發,並且視圖僅在延遲2秒後出現 - 我期望,2秒延遲一次視圖出現在屏幕上?iphone;只有在視圖出現之後才做東西..觀看會出現嗎?

我做錯了什麼? 我甚至嘗試過viewDidAppear,同樣的事情。有什麼建議麼?

感謝

編輯:我想給的我在做什麼

1. i have a parent view, which has a scroll view - and a subview 
2. In the parent view, i create multiple instances of the subview and add them to the scrollview, creating scrollable views, which work. 
3. Each view is passed an argument and depending on the argument the view contents change - works as expected. 
4. I would like to show the subview and once its on the screen, do some internet opearations while i show an activity indicator, for this i need to use viewDidApper. 
5. I am manually firing the subview's viewDidAppear from the parent view, once i have created its instance 

這裏的問題是,該視圖只出現一次所有的操作都完成一個明確的方案。

我該如何分類?

回答

5

viewWillAppear本應出現在視圖出現前,因此這個詞會在的名字中。您可能對viewDidAppear感興趣。

+0

@Abizern - 尼斯編輯隊友! :) – willcodejavaforfood 2010-12-02 10:24:53

1

我想我理解了它 - 而不是在viewDidAppear執行操作,我使用performSelector,像這樣

-(void) viewDidAppear:(BOOL)animated{ 
    [super viewDidAppear:animated]; 
    [self performSelector:@selector(loadXML:) withObject: self afterDelay:0]; 

} 

謝謝你們!

相關問題