Reputation: 297
I'm working on an app in which there is a social feed. I would really like to create a custom view with two tableViews side-by-side. I want to know how you would code this. Is it possible to intercept the scrolling of a table to move the other one at the exact time? Or maybe there is an easier way to achieve this?
I always say the is no limit in programming but the programmer limits. Here's mine.
Thank you for your ideas!
This what I want to do :
Upvotes: 0
Views: 250
Reputation: 20274
UITableView
objects are called:
tableView1
tableView2
[tableView1 setDelegate:self];
[tableView2 setDelegate:self];
NSInteger i_check;
globallyImplement these scrollView
delegate methods:
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView
{
if (scrollView == tableView1) {
i_check = 1;
}
else if (scrollView == tableView2) {
i_check = 2;
}
else { // just incase you have a scrollView that you don't want to track
i_check = 0;
}
}
-(void)scrollViewDidScroll:(UIScrollView *)scrollView
{
if (i_check == 1) {
[tableView2 setContentOffset:scrollView.contentOffset];
}
else if (i_check == 2) {
[tableView1 setContentOffset:scrollView.contentOffset];
}
}
A UITableView
internally uses a UIScrollView
and since the UITableViewDelegate
publicly declares UIScrollViewDelegate
, you can access all the scrollView
delegate methods by simply setting the tableView
object delegate (which you will be doing anyways)
Upvotes: 2
Reputation: 2551
It could be implemented with a UICollectionView
.
This should help you a good deal: https://www.cocoacontrols.com/controls/waterfallcollectionview
Upvotes: 1