Reputation: 1681
how would I access this code for determining which tableView is being used in a non tableView method?
I know how to use it in the tableView:numberOfRowsInSection:
method but how would I access it in a method I make?
do I use UITableView
instead of tableView?
-(void)myMethod {
if ([tableView isEqual:self.tableViewNode])
{
}
if ([tableView isEqual:self.tableViewCities])
{
}
}
I'm looking to see if a tableView is scrollViewDidEndDecelerating: and then perform an action.
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
// NSLog(@"scrollViewDidEndDecelerating");
if ([UITableView isEqual:self.tableViewNode])
{
float endScrolling = scrollView.contentOffset.y + scrollView.frame.size.height;
if (endScrolling >= scrollView.contentSize.height)
{
index ++;
[self getFeed:index];
}
}
if ([UITableView isEqual:self.tableViewCities])
{
}
}
Upvotes: 0
Views: 72
Reputation: 18363
Inside a UIScrollViewDelegate
method, you can compare the scrollView
argument to the table view properties.
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (self.firstTableView == scrollView) {
// respond to firstTableView scrolling
}
else if (self.secondTableView == scrollView) {
// respond to secondTableView scrolling
}
}
If you need to implement methods in your table view's delegate that are called by the delegate methods, but behave differently based on which table view called the calling method, then you should make those methods take a table view parameter and always pass the the table view argument of the delegate methods when you call them. Inside these methods, compare tableView
to your properties.
- (void)myMethod:(UITableView *)tableView
{
if (self.firstTableView == tableView) {
// do something for firstTableView
}
else if (self.secondTableView == tableView) {
// etc
}
}
If you needed to call myMethod:
from tableView:didSelectRowAtIndexPath:
for instance, you'd do something like this:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self myMethod:tableView];
}
Upvotes: 1