2012-03-24 19 views
5
- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *TodoListTableIdentifier = @"TodoListTableIdentifier"; 
    TodoTableViewCellController *cell = (TodoTableViewCellController *)[tableView dequeueReusableCellWithIdentifier:TodoListTableIdentifier]; 
    if (cell == nil) 
    { 
     NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil]; 
     cell=[nib objectAtIndex:0]; 
     [cell setSelectionStyle:UITableViewCellSelectionStyleGray]; 
    } 
    Todo *todo = [self.allTodoArray objectAtIndex:[indexPath row]]; 


    cell.titleLabel.text = todo.fileTitle; 
    cell.money.text = [NSString stringWithFormat:@"Monei:%f",todo.amount]; 
    cell.name.text = todo.realName; 
    cell.date.text = todo.operateTime; 

    return cell; 
} 

जब चल रहा है:कस्टम UITableViewCell NSUnknownKeyException

NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TodoTableViewCellController" owner:self options:nil]; 

और वहाँ एक अपवाद है: * समाप्त एप्लिकेशन न आया हुआ अपवाद 'NSUnknownKeyException', कारण की वजह से: '[setValue: forUndefinedKey:]: इस कुंजी महत्वपूर्ण तारीख के लिए महत्वपूर्ण मूल्य कोडिंग-अनुरूप नहीं है। '

मुझे नहीं पता कि ऐसा क्यों होता है, इसलिए कृपया इसके साथ मेरी मदद करें, अग्रिम धन्यवाद!

+0

संभावित डुप्लिकेट [यह वर्ग कुंजी के लिए महत्वपूर्ण मूल्य कोडिंग-अनुरूप नहीं है] (http://stackoverflow.com/questions/3088059/this-class-is-not-key-value-coding-compliant -for-the-key) – jtbandes

उत्तर

15

त्रुटि का मतलब है कि आपने अपने निब में तारीख नामक एक आउटलेट से कनेक्ट किया है लेकिन वह आउटलेट मौजूद नहीं है। आप तारीख कहां घोषित करते हैं?

+0

डेटा कस्टम सेल का एक लेबल है, और मैं इसे TodoTableViewCellController.h – jxdwinter

+0

में घोषित करता हूं क्या यह डेटा या दिनांक है? – borrrden

+0

अगला प्रश्न, आप loadNibNamed कहां कॉल करते हैं? – borrrden

2

TododTableViewController XIB (विशेष रूप से व्यू आउटलेट) में अपने सभी आउटलेट को हुक अप करें, और फिर से चलाएं।

1
  1. UITableViewCell पर फ़ाइल के स्वामी के Custom Class सेट करें।
  2. अपनी कस्टम तालिका दृश्य सेल myCustomCell पर सेल के Custom Class सेट करें।
  3. myCustomCell.h में आउटलेट करें।
+0

धन्यवाद, इस टिप्पणी ने मुझे बचाया! – Joshua