2015-05-07 90 views
2

我有這樣的代碼,設置了幾個標籤,皮革和其他幾個,然後刪除我從屏幕上做了一個自定義加載視圖,這裏是代碼:設置的UILabel隱藏

self.yourPlanLabel.text = [infoArray objectAtIndex:0]; 
self.yourMealLabel.text = [infoArray objectAtIndex:1]; 
self.yourBalanceLabel.text = [infoArray objectAtIndex:2]; 
self.usernameField.hidden = YES; 
self.passwordField.hidden = YES; 
self.loginBtn.hidden = YES; 
self.yourPlanLabel.hidden = NO; 
self.yourMealLabel.hidden = NO; 
self.yourBalanceLabel.hidden = NO; 
//remove loading view 
[self.loadingView removeFromSuperview]; 

但加載首先查看消失,然後幾秒鐘後標籤出現/消失,具體取決於我所設置的內容,爲什麼當加載視圖位於代碼的底部時,它首先消失?

感謝您的幫助:)

這裏是我的我是如何調用加載視圖:

self.loadingView = [[LoadingView alloc] initWithFrame:self.view.bounds]; 
[self.view addSubview:self.loadingView]; 
[self.navigationController.view addSubview:self.loadingView]; 
[self.loadingView setCenter:CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2 +32)]; 

這裏是加載視圖

https://gist.github.com/anonymous/e0a34fb49375dfeaca39

的.M我現在正在這樣做

dispatch_async(dispatch_get_main_queue(), ^{ 
    self.yourPlanLabel.text = [infoArray objectAtIndex:0]; 
    self.yourMealLabel.text = [infoArray objectAtIndex:1]; 
    self.yourBalanceLabel.text = [infoArray objectAtIndex:2]; 

    self.usernameField.hidden = YES; 
    self.passwordField.hidden = YES; 
    self.loginBtn.hidden = YES; 

    self.mealLabel.hidden = NO; 
    self.planLabel.hidden = NO; 
    self.balanceLabel.hidden = NO; 
    self.yourPlanLabel.hidden = NO; 
    self.yourMealLabel.hidden = NO; 
    self.yourBalanceLabel.hidden = NO; 
    self.loadingView.hidden = YES; 
    [self.loadingView removeFromSuperview]; 
}); 

仍然無法正常工作?

+0

Whhat是一個 「自定義加載視圖」?它怎麼叫? – zaph

+0

@Zaph你能看到編輯 –

+0

@timblue有沒有可能在主線程以外的線程上做這些事情? – JustSid

回答

0

如果您在viewDidLoad中進行了上述所有設置,請嘗試在 viewDidAppear中移動隱藏功能。

所以其

-(void)viewDidAppear 
{ 
     [self.loadingView removeFromSuperview]; 
}