2011-09-26 13 views
8

मुझे एक UITableView मिला है और सेलफॉररोएट इंडेक्सपैथ विधि के रूप में मैं सेल (फ़ॉन्ट, आकार इत्यादि) के कुछ विशेषताओं को बदल रहा हूं। अब नीचे सूचीबद्ध सभी असाइनमेंट केवल रंग को बदलने के अलावा ठीक काम करते हैं टेक्स्ट लेबल। मैं यह नहीं समझ सकता कि केवल वह विशिष्ट रंग विशेषता क्यों नहीं बदलेगी। मैंने हर जगह देखा है, मैं यह समझने के बारे में सोच सकता हूं कि यह क्यों काम नहीं कर रहा है और मैं फंस गया हूं। कोई विचार?UITableViewCell textLabel रंग बदल नहीं रहा

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *kLocationAttributeCellID = @"bAttributeCellID"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kLocationAttributeCellID]; 

    if (cell == nil) { 

     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:kLocationAttributeCellID] autorelease]; 

     cell.selectionStyle = UITableViewCellSelectionStyleBlue; 
     cell.detailTextLabel.font = [UIFont fontWithName:@"Helvetica" size:14.0]; 
     cell.detailTextLabel.numberOfLines = 0; 
     cell.detailTextLabel.lineBreakMode = UILineBreakModeWordWrap; 
     cell.userInteractionEnabled = NO; 
     cell.textLabel.font = [UIFont fontWithName:@"Courier" size:18.0]; 
     cell.textLabel.textColor = [UIColor redColor]; // this never takes effect... 
    } 

    cell.textLabel.text = @"Test Label"; 
    cell.detailTextLabel.text = @"Test Details"; 
    return cell; 
} 

उत्तर

9

यह इस वजह से है:

cell.userInteractionEnabled = NO; 

आप अपनी कोशिकाओं चयन होने के लिए नहीं करना चाहते हैं, इस के बजाय का उपयोग करके देखें:

cell.selectionStyle = UITableViewCellSelectionStyleNone; 
+1

ओह वाह ... क्या बकवास । मुझे आश्चर्य है कि इसका रंग पर असर क्यों पड़ता है। मैं इसे 3 दिनों के लिए हल करने की कोशिश कर रहा हूं। धन्यवाद!!! – gplocke

+0

बहुत बहुत धन्यवाद !! घूमने के घंटों के बारे में सोचते हुए ... – ewiinnnnn

संबंधित मुद्दे