0
votes

2 Tableviews in a ViewController with different size of cell height. When i scroll on the view controller , need to scroll both tableview cell at same time also both table cells also need to hide at same time.

200px height of cell in top tableview, 50px height of bottom tableview.

when i swipe 100px , top table cell scrolls 100 px and bottom table cell should be scrolled 25px.

is this parallel scrolling any possible? any suggestion.. Thanks in advance

2

2 Answers

5
votes

As UITableview is derived from UIScrollview you can get the scroll amounts in the delegate method

- (void)scrollViewDidScroll:(UIScrollView *)scrollView 

You can get content offset of the scrollview which is being scrolled and assign that to the other tableview.

In this method you should be able to access both tableviews.

The property you need to check is contentOffset.

firsttableview.contentOffset = scrollview.contentOffset
2
votes

You can use this function of UIScrollView to scroll multiples UITables parallel

func scrollViewDidScroll(scrollView: UIScrollView) {

    if scrollView == tableView1 {
        self.tableView1.contentOffset = CGPointMake(0, scrollView.contentOffset.y)
        self.tableView2.contentOffset = CGPointMake(0, scrollView.contentOffset.y)
    }
    else if scrollView == self.tableView2!
    {
        self.tableView1.contentOffset = CGPointMake(0, scrollView.contentOffset.y)
    }
    else if scrollView == self.bottomMenu_grid!
    {
        print(scrollView.contentOffset.x)
        self.tableView2.contentOffset = CGPointMake(scrollView.contentOffset.x, scrollView.contentOffset.y)
    }
}