2012-08-24 121 views
-2

我正在使用IOS 5的故事板。 由於繁重的圖像處理,我需要在viewdidload中加載加載視圖。 它沒有調出加載視圖。我在不同的地方嘗試了下面的代碼,它工作。只是不在viewdidload。IOS在viewdidload上添加加載視圖

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(notify_action_finish:) name:@"StopLoadingView" object:nil]; 
loadingView =[tfbLoadingView loadingViewInView:[self.view.window.subviews objectAtIndex:0]]; 

在此先感謝。

+0

無法從代碼中判斷出你在做什麼,但是你在使用UIActivityIndi​​catorView嗎?我猜你需要分配一個uiactivityindicatorview,將它作爲子視圖設置爲當前視圖的框架,然後開始動畫。 – Augie

+0

閱讀說明。 – user1302602

+1

使用MBProgressHud在viewdidload中顯示加載視圖,然後在圖像處理完成後隱藏它。 – Eric

回答

1

正如埃裏克說,在他的評論中,使用MBProgressHud裝載觀點..

添加HUD作爲窗口的子視圖。

// Should be initialized with the windows frame so the HUD disables all user input by covering the entire screen 
    HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow]; 

    // Add HUD to screen 
    [self.view.window addSubview:HUD]; 

    // Register for HUD callbacks so we can remove it from the window at the right time 
    HUD.delegate = self; 

    HUD.labelText = NSLocalizedString(@"Loading Workbench", nil); 
    HUD.detailsLabelText = NSLocalizedString(@"please wait", nil); 

    // Show the HUD while the provided method executes in a new thread 
    [HUD showWhileExecuting:@selector(loadWorkbench:) onTarget:self withObject:nil animated:YES]; 

添加下面的委託方法:

- (void)hudWasHidden { 
    // Remove HUD from screen 
    [HUD removeFromSuperview]; 

    // add here the code you may need 

} 

而且不要忘記在相應的頭文件添加MBProgressHUDDelegate