In-place editing of text in UITableViewCell?

前端 未结 2 1651
礼貌的吻别
礼貌的吻别 2020-12-09 13:00

I know this has to be a really simple question, but I am having trouble finding it in a simple place where there aren\'t so many other things going on that I can isolate the

2条回答
  •  Happy的楠姐
    2020-12-09 13:11

    First, define about UITextField.

    txtField=[[UITextField alloc]initWithFrame:CGRectMake(5, 5, 320, 39)];
    txtField.autoresizingMask=UIViewAutoresizingFlexibleHeight;
    txtField.autoresizesSubviews=YES;
    txtField.layer.cornerRadius=10.0;
    [txtField setBorderStyle:UITextBorderStyleRoundedRect];
    [txtField setPlaceholder:@"Type Data Here"];
    

    Then write the code below in cellForRowAtIndexPath method

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
         static NSString *CellIdentifier = @"CellIdentifier";
         UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
       if (cell == nil)
       {
          cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
          cell.accessoryType = UITableViewCellAccessoryNone;
        }
        [cell addSubview:txtField];
        return cell;
    }
    

提交回复
热议问题