2016-08-04 68 views
0

因此,我在視圖控制器上顯示了模型控制器。我在模型控制器中有文本,但不知何故文本不可見。我嘗試了一切,但不知何故標籤不可見。但是,你停留在頁面上,等待30-40秒,文本就會顯示出來。此外,此模型控制器在成功服務(REST)調用後從主視圖控制器中調用。如果我不打電話給該模型,那麼標籤在模擬器/ iPad中都可見。但是如果我在成功塊內部調用服務之後調用它,則標籤不可見。我嘗試以編程方式添加文本,但仍然是同樣的問題。我嘗試使用Color混合圖層進行調試,但標籤在視圖中完全不可見。 :(UILabel在模擬器或iPad中均未顯示

[self.serviceManager getCustDetails:account successBlock:^(NSDictionary * successDict) { 
    [self hideLoadingAnimation]; 
    NSDictionary *custData = [[successDict objectForKey:@"txnData"] objectForKey:@"custData"]; 

    self.showCurrYear = [iraContribData objectForKey:@"showCurrYear"]; 

    if ([self.showCurrYear isEqual: @"true"]){ 
    [self performSegueWithIdentifier:@"CSegue" sender:self]; 
    } 

    } failureBlock:^(NSDictionary * failureDict) { 
     [self hideLoadingAnimation]; 
     NSLog(@"Failiure Dict %@",failureDict); 
    }]; 

這prepareForSegue方法, -

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
    { 
     if([segue.identifier isEqualToString:@"CSegue"]) { 
      CustViewController *cVC = segue.destinationViewController; 
      cVC.delegate = self; 
      [cVC setModalPresentationStyle:UIModalPresentationFormSheet]; 
      cVC.preferredContentSize = CGSizeMake(800,750); 
     } 
    } 

下面是我在故事板的屏幕,但在模擬器中的標籤是不可見的,只有繼續和關閉按鈕可見

enter image description here

請大家幫忙!歡迎提供任何建議。謝謝!

+0

如果您在成功塊設置斷點,難道是被立刻打?或者只有在那30-40秒之後? –

+0

立即命中,模型出現,但標籤不可見。 –

回答

1

延遲可能是由於未在主線程上進行用戶界面更新所致。

嘗試,以確保您的代碼使用dispatch_async這樣在主線程上執行:

[self.serviceManager getCustDetails:account successBlock:^(NSDictionary * successDict) { 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self hideLoadingAnimation]; 
     NSDictionary *custData = [[successDict objectForKey:@"txnData"] objectForKey:@"custData"]; 

     self.showCurrYear = [iraContribData objectForKey:@"showCurrYear"]; 

     if ([self.showCurrYear isEqualToString:@"true"]){ 
      [self performSegueWithIdentifier:@"CSegue" sender:self]; 
     } 
    }); 
} failureBlock:^(NSDictionary * failureDict) { 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self hideLoadingAnimation]; 
     NSLog(@"Failiure Dict %@",failureDict); 
    }); 
}]; 
+0

就是這樣,你真棒! ,非常感謝。我在這一天浪費了我整整一天的時間。謝謝你太多了。 –