问题来了:
我在现有的表格 View Controller E 之上展示了一个弹出表格 View Controller P。
我遇到的问题是 E 仍然滚动。这意味着如果您滚动到 P 的边界之外,E 将滚动,并且 P 将表现得好像它是 E 的一部分。
如何在 P 显示时禁用 E 滚动?
最佳答案
当您呈现 P 时,设置:
yourTableView.isScrollEnabled = false
当您关闭弹出窗口时:
yourTableView.isScrollEnabled = true
注意:也许您需要使用协议(protocol)在关闭弹出窗口时再次启用滚动。
为此,我将在您的弹出 View Controller 中添加:
protocol ProtocolPopOver{
func enableScrollAgain();
}
然后,在该 View Controller 中:
var delegatePopOver:ProtoclPopOver?
当你关闭 viewController 时:
self.dismiss(animated: true, completion: { delegatePopOver.enableScrollAgain() })
在主视图 Controller 中,当您呈现弹出窗口时,添加:
popoverViewController.delegatePopOver = self
在 UIViewController 附近实现协议(protocol):
class yourclass: UIViewController, ProtocolPopOver{...
并添加功能:
func enableScrollAgain(){
yourTableView.isScrollEnable = true
}
关于ios - 禁用 TableView 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42280529/