UITextField 中的文本在 UITableView 中消失,如果滚动 UITableView
我在 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
提前致谢
I have a problem on UITableView,If i placed UITextField in UITableView,the entered text in UITextField is deleted,if scroll the UITableView. Any way to keep that data in UITextField.
I have used the below code
- (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;
}
I have designed the UITableViewCell
using the xib
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
取消选中表视图 xib 文件中的自动调整子视图大小。
并将可编辑的否设置为文本字段
Un check the auto resize subvies in table view xib file.
and set editable no to the textfiled