我在自定义UITableViewCell中有一个UITextView。我遇到的问题与resignFirstResponder有关。当调用resignFirstResponder并关闭UI键盘时,UITextView向上滚动一行,使得输入在单元格的顶部只有一半可见。
创建UITextView时,我是否遗漏了以下代码中的内容?
if (indexPath.row == 0) {
// Load the cell with the comment textView
cell = (DetailCellViewController *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier3];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"DetailCellView3"
owner:nil
options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:[UITableViewCell class]]) {
cell = (DetailCellViewController *) currentObject;
break;
}
}
}
self.textView = [[UITextView alloc] initWithFrame:cell.contentView.bounds];
self.textView.backgroundColor = [UIColor clearColor];
self.textView.textColor = [UIColor blackColor];
self.textView.returnKeyType = UIReturnKeySend;
self.textView.enablesReturnKeyAutomatically = YES;
self.textView.editable = YES;
self.textView.scrollEnabled = YES;
self.textView.opaque =YES;
self.textView.clipsToBounds = YES;
self.textView.autocorrectionType = UITextAutocorrectionTypeNo;
self.textView.delegate = self;
self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
[cell.contentView addSubview:textView];
[textView release];
return cell;
答案 0 :(得分:2)
设置self.textView.contentInset = UIEdgeInsetsZero;