2014-02-15 54 views
0

我试图更改自定义UITableViewCell中的自定义标签中的文本颜色。didSelectRowAtIndexPath - colorText更改未立即更新

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 

{ 

////////////////////// 
// Unselect the prevoius selected Cell and select this one 
WSLanguageTableViewCell *aPreviousSelectedCell= (WSLanguageTableViewCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:selectedRow inSection:0]]; 
aPreviousSelectedCell.languageLabel.textColor = [UIColor lightGrayColor]; 

// Select the new one 
WSLanguageTableViewCell *aSelectedCell = (WSLanguageTableViewCell*)[self.tableView cellForRowAtIndexPath:indexPath]; 
aSelectedCell.languageLabel.textColor = [UIColor colorLanguageCellLanguageLabelText]; 

selectedRow = indexPath.row; 


/////////////////////// 
// Get the new language 
PFObject* languageObject = [self.objects objectAtIndex:indexPath.row]; 
NSString* language = [languageObject objectForKey:kWSLanguageNameKey]; 


////////////////////// 
// Check if it's setup -- if not, then show alert 
if (![[languageObject objectForKey:kWSLanguageIsSetupKey] boolValue]) { 
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:kPromptChangeLanguageNotSetup message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:@"OK", nil]; 
    [alert show]; 

    return; 
} 


////////////////////// 
// Check if it's the current language -- only change if not 
if (![language isEqualToString:[[WSWordlistManager shared] languageTarget]]) { 


    // Show HUD view 
    AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 
    [appDel showGlobalProgressHUDWithTitle:kLocalizedChangingLanguage]; 


    ////////////////////// 
    // Load the wordlist 
    [[WSWordlistManager shared] loadWordlist:language completion:^() { 


     ////////////////////// 
     // Add the language to user (and vice versa) in DB 
     [WSUserManager addLanguage:language forUser:[PFUser currentUser]]; 


     /////////////////// 
     // Reload User Words 
     WSDatabaseManager* databaseManager = [[WSDatabaseManager alloc] init]; 
     [databaseManager retrieveUserWordlistForCurrentUserWithCallback:^(NSError *error) { 


      // Dismiss the HUD 
      AppDelegate *appDel = (AppDelegate *)[[UIApplication sharedApplication]delegate]; 
      [appDel dismissGlobalHUD]; 


      // Navigate to root 
      [self.navigationController popToRootViewControllerAnimated:YES]; 

     }]; 

    }];   
} 

}

的问题是,所述颜色变化被延迟了一段时间。如果我在6行以下设置两个单元格的textColor,则该变化是即时的。在更改textColor后,我会立即运行哪些方法以显示?

回答

0

检查UILabel的highlightedTextColor属性。这是更改所选单元格标签颜色的正确方法。