gpt4 book ai didi

iphone - UITableViewCell 中的 UITextView

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:25:57 26 4
gpt4 key购买 nike

我在自定义 UITableViewCell 中有一个 UITextView。我遇到的问题与 resignFirstResponder 有关。当 resignFirstResponder 被调用并且 UIkeyboard 被关闭时,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;

最佳答案

设置self.textView.contentInset = UIEdgeInsetsZero;

关于iphone - UITableViewCell 中的 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7022205/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com