I am using both a UITableView
and UIScrollView
inside the same UIViewController
.
My problem is when I scroll either the table view or scroll view the didScroll delegate call is fired.
How can i identify the source of the scrollViewDidScroll
delegate call?
check the scrollView parameter given in the delegate.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
if(scrollView == self.tableView) {
// its your tableView
}
else if(scrollView == self.scrollView) {
// its your scrollView
}
}
The didScroll method takes in a scrollview as an input
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
if(scrollView == self.tableViewInstance){//this is your table view}
else {//this is your scroll view}
}
You can check the input and see whether it is your scrollview or tableview which is calling the delegate method.
You can add tag for UIScrollView as 0
and add tag for UITableView as 1
. Inside the delegate check for the tag to know which of this is scrolled and do your stuff:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if(scrollViewl.tag == 0) // ur in scrollView
if(scrollViewl.tag == 1) // ur in tableView
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With