2012-03-24 13 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

dataはカスタムセルのラベルで、TodoTableViewCellController.hで宣言します。 – jxdwinter

+0

データまたは日付ですか? – borrrden

+0

次の質問は、どこでloadNibNamedを呼び出しますか? – borrrden

2

TododTableViewController XIB(特にビューアウトレット)でアウトレットをすべて連結して再実行します。

1
  1. ファイル所有者の​​をUITableViewCellに設定します。
  2. セルのカスタムテーブルビューセルクラス​​をmyCustomCellに設定します。
  3. アウトレットUIlabelmyCustomCell.hにします。
+0

ありがとう、このコメントは私を救った! – Joshua

関連する問題