我已經創建了UITableView
和UITableview
每行都有一個以上UITextField
。如何獲得每個UITextField
值。以下是我的示例代碼。如何解決這個錯誤「這個類不是密鑰的關鍵值編碼」?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
int j= 285;
for (int i=0; i<7; i++) {
NSString *txtIndvalue =[NSString stringWithFormat:@"Index%d",i];
UITextField *txtvalue = [[UITextField alloc] initWithFrame:CGRectMake(j,5.0f,25.0f,20.0f)];
[txtvalue setBorderStyle:UITextBorderStyleLine];
[txtvalue setTag:indexpath.row]
[txtvalue setvalue:txtIndvalue forkey:@"test"]
[cell addSubview:txtvalue];
j = j + 35;
}
}
error: Terminating app due to uncaught exception 'NSUnknownkeyException' ,reason :'[<UItextField .>' setValue:forUndefindekey:] this class is not key value codeing compliant for the key. Please help me.
[txtvalue的setValue:txtIndvalue forkey:@ 「測試」 ]是UITextField的一個方法/屬性。 void setvalue:(id)forkey:(NSString *)。請你再檢查一次。如何爲每個文本框的每一行賦值。 – Baskar
請檢查下面@BEN添加的答案。他正在使用KVC/KVO模式進行設置。 –
任何示例代碼 – Baskar