temp
temp

Reputation: 649

Disable Table View Scrolling

Heres the problem:

I am presenting a popover tableview controller P on-top of an existing tableview controller E.

The issue I run into is E still scrolls. Meaning if you scroll outside of the bounds of P, E will scroll and P will act as if it is apart of E.

How can I disable E from scrolling while P is presented?

Upvotes: 2

Views: 650

Answers (1)

J Manuel
J Manuel

Reputation: 3070

When you present P, set:

yourTableView.isScrollEnabled = false

And when you close your popover:

yourTableView.isScrollEnabled = true

Note: Maybe you will want to use a Protocol to enable the scroll again when you close your popover.

For that, I would add in your popover View Controller:

protocol ProtocolPopOver{
  func enableScrollAgain();
}

Then, in that view controller:

var delegatePopOver:ProtoclPopOver?

And when you close your viewController:

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

In your main view controller, when you present the popover, add:

popoverViewController.delegatePopOver = self

Implement the protocol near UIViewController:

class yourclass: UIViewController, ProtocolPopOver{...

And add the function:

func enableScrollAgain(){
 yourTableView.isScrollEnable = true
}

Upvotes: 3

Related Questions