[英]UITableViewController resizing TableView sporadically
我的应用程序中有一些UITableViewControllers
。 我在某些UITableViewCells
有UITextFields
。 有时,当键盘出现时, tableView
调整大小,但并非总是如此。
我已经举了几个例子。 两者都有一个UITextField
,它们是当前的firstResponder
。 我都拖动了两个屏幕快照以显示滚动指示器。
出现键盘时,左侧的UITableViewController
调整为tableView
大小,但右侧的UITableViewController
没有。 我究竟做错了什么?
编辑
感谢大家在这个问题上为我提供帮助。 仍然没有解决。 它们都具有UINavigationController
作为其parentViewController
。 右边的一个是UINavigationControllers
topViewController
而左边的一个是topViewController
呈现的。 任何帮助,将不胜感激。
因此,我想出了一种解决方法:
- (void)setContentInsetWithTextField:(UITextField *)textField
{
CGFloat keyboardHeight = 216;
CGFloat movement = (textField.isFirstResponder ? keyboardHeight : -keyboardHeight);
UIEdgeInsets contentInset = self.tableView.contentInset;
contentInset.bottom = contentInset.bottom + movement;
self.tableView.contentInset = contentInset;
}
在textFieldDidBeginEditing
和textFieldDidEndEditing
调用此方法即可解决问题!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.