【发布时间】:2018-05-27 00:52:16
【问题描述】:
我正在使用 UITableview 单元格列出一组问题,2 个文本字段用于分数 1 和分数 2 我输入了分数和总分显示在标签上之后,当我滚动时,输入的数据在 UITableview 上消失了。一些请帮我解决这个问题,并在视图上添加这些文本字段和标签,这个视图是 cell.contentview 的子视图
-(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];
}
else{
for (UIView* view in cell.contentView.subviews) {
if ([view isKindOfClass:[UIView class]]) {
[view removeFromSuperview];
}
}
}
文本字段添加为
UIView * vwbackground = [[UIView alloc] init];
[vwbackground setFrame: CGRectMake(5.0, 5.0, [UIScreen mainScreen].bounds.size.width-10, 90)];
vwbackground.backgroundColor = [UIColor whiteColor];
[cell.contentView addSubview:vwbackground];
self.txtfldInPut1.clearButtonMode = UITextFieldViewModeWhileEditing;
self.txtfldInPut1.autocorrectionType = UITextAutocorrectionTypeNo;
self.txtfldInPut1.inputAccessoryView = numberToolbar;
[vwbackground addSubview:self.txtfldInPut1];
【问题讨论】:
标签: ios xcode uitableview uiscrollview uitextfield