OGeek|极客世界-中国程序员成长平台

标题: ios - 禁用表格 View 滚动 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:55
标题: ios - 禁用表格 View 滚动

问题来了:

我在现有的 tableview Controller E 之上展示了一个 popover tableview Controller P。

我遇到的问题是 E 仍然滚动。这意味着如果您滚动到 P 的范围之外,E 将滚动并且 P 将表现得好像它是 E 的一部分。

如何在显示 P 时禁用 E 滚动?



Best Answer-推荐答案


当你呈现 P 时,设置:

yourTableView.isScrollEnabled = false

当你关闭你的弹出框时:

yourTableView.isScrollEnabled = true

注意:当您关闭弹出框时,您可能希望使用协议(protocol)再次启用滚动。

为此,我将在您的弹出 View Controller 中添加:

protocol ProtocolPopOver{
  func enableScrollAgain();
}

然后,在那个 View Controller 中:

var delegatePopOverrotoclPopOver?

当你关闭你的 viewController 时:

self.dismiss(animated: true, completion: { delegatePopOver.enableScrollAgain() })

在您的主视图 Controller 中,当您呈现弹出框时,添加:

popoverViewController.delegatePopOver = self

在 UIViewController 附近实现协议(protocol):

class yourclass: UIViewController, ProtocolPopOver{...

并添加功能:

func enableScrollAgain(){
 yourTableView.isScrollEnable = true
}

关于ios - 禁用表格 View 滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42280529/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4