【问题标题】:The text from UITextField is disappear in UITableView,If scroll the UITableViewUITextField 中的文本在 UITableView 中消失,如果滚动 UITableView
【发布时间】:2013-10-08 21:16:42
【问题描述】:

我在 UITableView 上有问题,如果我将 UITextField 放在 UITableView 中,如果滚动 UITableView,UITextField 中输入的文本将被删除。将这些数据保存在 UITextField 中的任何方式。

我使用了下面的代码

- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cell_ID=@"CELL_ID";
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:cell_ID];

    if(cell==nil)
    {
        NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"TableViewCellView" owner:self options:nil];
        if([nib count]>0)
        {
            cell=[nib objectAtIndex:0];
        }
        else
        {
            NSLog(@"Failed to load nib");
        }
    }

    UITextField *txt1=(UITextField*)[cell viewWithTag:1];//not needed

    return cell;

}

我使用 xib 设计了UITableViewCell

提前致谢

【问题讨论】:

  • 您是否尝试在表格视图中的 uitextfields 中使用输入数据。然后你应该重新加载你的表格视图。输入数据后
  • 我已经在 UITextField 中动态输入了数据,
  • 你能用rowatindexpath方法显示你的单元格吗?
  • 请出示您使用的代码。
  • 我已经包含了代码,现在请检查一下-我已经使用 xib 设计了 ​​UITableViewCell

标签: objective-c uitableview uitextfield


【解决方案1】:

取消选中表格视图 xib 文件中的自动调整大小子视图。 并为文本文件设置可编辑否

【讨论】:

    猜你喜欢
    • 2011-08-22
    • 1970-01-01
    • 2017-08-31
    • 1970-01-01
    • 1970-01-01
    • 2011-01-13
    • 2015-03-11
    • 1970-01-01
    相关资源
    最近更新 更多