我正在制作一个iPhone应用程序,我希望当应用程序加载它时,应该只有一个单元格与文本字段时,用户在第一个单元格中输入任何数据它应该与输入数据的新单元格和第一个单元格应该是可编辑的空白。 我正在做,但它也显示在上面的单元格相同的值。如何插入UITextField顶部行iphone应用程序
这里是代码
-(UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
if (!cell) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
cell.backgroundView = [[UIImageView alloc] initWithImage:[ [UIImage imageNamed:@"tabelsales.png"] stretchableImageWithLeftCapWidth:0.0 topCapHeight:5.0] ];
cell.backgroundColor = [UIColor clearColor];
}
if (indexPath.section==0) {
tagInputField =[[UITextField alloc]initWithFrame:CGRectMake(13, 6, 250, 26)];
tagInputField.tag = 2;
tagInputField.delegate = self;
tagInputField.clearButtonMode = UITextFieldViewModeWhileEditing;
tagInputField.font=[UIFont fontWithName:@"Myriad-Pro" size:8];
[tagInputField setText:@" "];
tagInputField.textColor =[UIColor grayColor];
[cell addSubview:tagInputField];
[email protected]"";
return cell;
}
if (indexPath.section==1) {
UIButton *crossButton =[[UIButton alloc]initWithFrame:CGRectMake(230, 8, 18, 18)];
//crossButton.backgroundColor = [UIColor purpleColor];
crossButton.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"Cross.png"]];
[cell addSubview:crossButton];
cell.textLabel.font =[UIFont systemFontOfSize:13];
cell.textLabel.textColor =[UIColor grayColor];
cell.textLabel.text =[tagArray objectAtIndex:indexPath.row];
[crossButton addTarget:self action:@selector(deleteCell:) forControlEvents:UIControlEventTouchUpInside];
return cell;
}
}
的问题是在你的代码。你需要分享你的代码。 –
@SarwarErfan添加代码请检查 –
尝试使用我发布的更新后的代码。让我知道它是否有效。 –