0
votes

i got a tableview and as a header i use amongst other things a scrollview. All work ok in terms of scrolling apart from the fact that when i scroll down (or up) the tableview the scrollview "loses" the x,y coordinates.

for example if i scroll the scrollview on the headerview right to left (or vice versa) then the scrollOffset.x gets a value. if i start scrolling the tableview then this value goes back to zero (although the scrollview doesnt lose the paging). If i go back to the scrollview and start scrolling again the scrollOffset.x gets its correct value again.

Anyway to "keep" the scrollOffset.x value when i scroll the tableview?

thanks

1
Just as a note, I believe putting scroll views inside scroll views, or objects that subclass scrollviews inside scrollviews, is contraindicated. In other words, putting a scrollview inside a UITableView is guaranteed to not work reliably by Apple.RonLugge
@RonLugge that's true, we should always follow the HIG but creativity is also a necessity in good programming. ;) I believe that the problem you're having is using two scrollViews is causing the value to be represent the other second scrollView(your tableView). This is supported by the fact that you typically can't scroll tableViews horizontally.erran
@ipwnstuff I've ignored that rule myself a few times, but I just wanted to throw out that if you CAN avoid it, you really, really should.RonLugge
I can't argue with that! It's sad seeing good ideas getting mucky.erran
Where does HIG says that we shouldn't have scrollview inside tableview?George Asda

1 Answers

1
votes

Considering that a tableView is a scrollView subclassed it seems like the problem is that scrollOffset.x is set by whichever scrollView you're currently scrolling inside of. Try adding tags to your table view and scroll view and add a variable to keep up with the scrollOffset.x for only the scrollView in your header.