2
我是新来的iphone世界..帮助我摆脱这个。UITableView中的TextField
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *MYIdentifier [email protected]"MyIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MYIdentifier];
if(cell==nil)
{
cell=[[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MYIdentifier] autorelease];
}
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];
NSInteger fid=editFrndBDb.friendId;
if(name.text==NULL)
[email protected]" ";
if(bday.text!=NULL)
[email protected]" ";
if(note.text!=NULL)
[email protected]" ";
[editFrndBDb editFriendInfo:name.text frndBdayIs:bday.text frndNoteIs:note.text frndIdIs:fid];
}
得到错误的saveChange法在声明
UITextField *name= (UITextField *)[self.viewWithTag:1];
错误信息: -
"viewWithTag is some thing not a structure or a union:"
帮我出这...
我已经试过[自viewWithTag:3],但使用这种有例外发生的历史....这行.. – 2009-12-03 13:51:17
你也有[个体经营viewWithTag:2]和[self viewWithTag:1]也改变这些 – 2009-12-03 13:53:35