gpt4 book ai didi

ios - 当键盘出现时,带有大单元格的 UITableViewController 会崩溃,隐藏 UITextView

转载 作者:行者123 更新时间:2023-11-28 17:53:38 26 4
gpt4 key购买 nike

我创建了一个新项目来测试它。

演示

创建主从项目。在 Main_iPhone.storyboard 上:

  1. 将原型(prototype)单元格样式更改为自定义。
  2. 将表格 View 的行高设置为 504 以用每个单元格填充整个屏幕。
  3. UITextView 填充到原型(prototype)单元格的下半部分。
  4. MasterViewController.m 中,从 cellForRowAtIndexPath: 中删除这一行:
cell.textLabel.text = [object description];

运行项目并添加一些单元格。然后点击 TextView 以编辑内容。

问题描述

每次我点击 TextView 时,单元格都会向上滚动以暂时显示 TextView (这是应该的),然后向下滚动以便单元格的顶部可见,这将 TextView 隐藏在键盘。

视频

这个问题有问题的视频:UITableView in iOS 7 not scrolling to correct location when editing UITextView in cell

问题

这可能是什么原因造成的?你能找到任何关于 UITableViewController 如何处理键盘的 Apple 文档吗?

最佳答案

我能够使用 TPKeyboardAvoidingTableView 解决这个问题并将其添加到我的 UITableViewController 子类中:

- (void)viewWillAppear:(BOOL)animated
{
// Removed to avoid default tableview scrolling behavior when the keyboard appears
//[super viewWillAppear:animated];
}

仅使用 TPKeyboardAvoidingTableView仅此一项是不够的,因为 UITableViewController 的默认行为会覆盖它。阻止 viewWillAppear 运行是我能找到的阻止该行为的唯一方法。但我不喜欢这个解决方案,因为我不知道我还会失去什么。

关于ios - 当键盘出现时,带有大单元格的 UITableViewController 会崩溃,隐藏 UITextView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23000576/

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