I have an application, in which I have a UITableView
inside a UIView
, which is again inside a UIScrollView
, so the hierarchy becomes like this:
UIScrollView
-> UIView
-> UITableView
The data inside my UITableView
is filled properly.
Now, my problem is that, When I scroll my UITableView
, the UIScrollView's
delegate method scrollViewDidEndDecelerating:
and scrollViewDidEndDragging::
gets called.
I don't want this behavior, what should I do to stop this behavior?
Any one please Help, Thank in advance!!!
Methods for managing selections, configuring section headers and footers, deleting and reordering cells, and performing other actions in a table view.
Delegate Methods in UITableView. willDisplay: This method gets called when the table view cell is going to display on the screen. willDisplayHeaderView: This method gets called when the header view of the section will be display.
Datasource methods are used to generate tableView cells,header and footer before they are displaying.. Delegate methods provide information about these cells, header and footer along with other user action handlers like cell selection and edit..
UITableViewDelegate extends UIScrollViewDelegate. Hence the calling of the delegate methods.
To stop this you can set tableView.tag = 1000;
when you alloc the tableView and in the UIScrollViewDelegate methods ( scrollViewDidEndDecelerating: and scrollViewDidEndDragging::
)add this at the very begining:
if(scrollView.tag == 1000)
return;
Because UITableView inherits from UIScrollView. So it shows all the properties and behaviours of UIScrollView. If you dont want this then please do one thing.
Assuming you have another scrollview in your page.
in the viewDidLoad
or from the XIB
(if you have your tableview in the XIB), set a tag for your tableview.
in code,
self.objYourTableView.tag = 101;
then in the scroll view delegate
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView
{
if(!(scrollView.tag == 101))
{
// Go for your code to run.
}
}
So that your code will skip if it called by the table view. Other cases it works perfect. Hope this will help you.
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