我新來iphone ...嘗試此代碼,但收到的一些錯誤幫我..文本字段中的UITableView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
........//// some code ...........//////////
CGRect frame = CGRectMake(5 ,10 , 320, 44);
UITextField *txtField = [[UITextField alloc]initWithFrame:frame];
[txtField setBorderStyle:UITextBorderStyleNone];
txtField.delegate=self;
switch (indexPath.row) {
case 0:
txtField.placeholder=editFrndBDb.frndName;
txtField.text=editFrndBDb.frndName;
txtField.tag=1;
break;
case 1:
txtField.placeholder=editFrndBDb.bDay;
txtField.text=editFrndBDb.bDay;
txtField.tag=2;
break;
case 2:
txtField.placeholder=editFrndBDb.frndNote;
txtField.text=editFrndBDb.frndNote;
txtField.tag=3;
break;
default:
break;
}
[cell.contentView addSubview:txtField];
[txtField release];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
return cell;
}
-(IBAction) saveChanges:(id) sender
{
UITextField *name =(UITextField *)[self.viewWithTag:1];
UITextField *bday= (UITextField *)[self.viewWithTag:2];
UITextField *note=(UITextField *)[self.viewWithTag:3];
//// some code ////////////
I M使用此代碼顯示在tableview中文本框,然後從文本框訪問該值。但在「saveChange」方法「UITextField * name =(UITextField *)[self.viewWithTag:1]」中獲取錯誤「錯誤: - 視圖不是結構或聯合。 plz me out of this