How to enable UIScrollView scroll on a nested UITableView while dragging a cell?

I have a UIScrollView with a UILabel + UITableView as a subview. Here is how it looks in a Storyboard: https://cln.sh/k2QiFS

In my tableView I have implemented a drag and drop for its cells through edit mode. When I drag a cell and move it down to the bottom of the tableView, the scrollView doesn't scroll and not showing cells which is currently out of the visible area.

So I should drop the cell, scroll the UIScrollView manually and again drag the cell.

Here is the behaviour on GIF: https://cln.sh/j45g83

If I get rid out of scrollView, the basic tableView behaviour automatically scrolls to the up/bottom, but the reason I added the scrollView is to be able the UILabel be scrolled too.

Here is my code for moveRowAt():

func tableView(_ tableView: UITableView, moveRowAt sourceIndexPath: IndexPath, to destinationIndexPath: IndexPath) {
    var currencies = fetchedResultsController.fetchedObjects!
    let currency = fetchedResultsController.object(at: sourceIndexPath)
            
    currencies.remove(at: sourceIndexPath.row)
    currencies.insert(currency, at: destinationIndexPath.row)
    
    for (index, currency) in currencies.enumerated() {
        currency.rowForCurrency = Int32(index)
    }
    coreDataManager.save()
}

How can I turn on a scroll for my UIScrollView?

Answered by Claude31 in 705407022

What is the UILabel Here on GIF: https://cln.sh/j45g83 ?

When do you want the label to move ? When you scroll the tableView ?

If so, why not just put this label in HeaderView of the table ?

Having a tableView (which is a scrollView) inside another scrollView is complex to handle.

See discussion here:

https://stackoverflow.com/questions/33292427/how-to-make-the-scroll-of-a-tableview-inside-scrollview-behave-naturally

Accepted Answer

What is the UILabel Here on GIF: https://cln.sh/j45g83 ?

When do you want the label to move ? When you scroll the tableView ?

If so, why not just put this label in HeaderView of the table ?

Having a tableView (which is a scrollView) inside another scrollView is complex to handle.

See discussion here:

https://stackoverflow.com/questions/33292427/how-to-make-the-scroll-of-a-tableview-inside-scrollview-behave-naturally

What is the UILabel Here on GIF: https ://cln.sh/j45g83 ?

It's a grey text just below the searchBar and before the first cell. Take a look I made a new gif for you: https://cln.sh/ajHYYt

When do you want the label to move ? When you scroll the tableView ?

Yes, when I drag tableView, label should follow

If so, why not just put this label in HeaderView of the table ?

Can I put it just like it shows now? (right aligned, the same color and size) Can you suggest how can I move it correctly?

Having a tableView (which is a scrollView) inside another scrollView is complex to handle.

Basically I can't scroll my tableView. It has a fixed size since I have the exact amount of cells and it's not possible to delete or add to it. Just reorder. The only reason I put it all inside a scrollView is to be able to interact with a Navigation Bar Large Title: if I put a label before TableView without scrollView, then when I drag tableView up - the NavBar won't animate (going up), it will be like fixed since label will interfere...

Two scroll views scrolling in the same direction is generally not really a recommended setup in UIKit and cause all sorts of problems. So I would recommend you to re-think your setup here. Presumably whatever you are trying to do can be done with a collection view and a list section.

How to enable UIScrollView scroll on a nested UITableView while dragging a cell?
 
 
Q