Merge pull request #1261 from vector-im/scrollback_collections_to_the_left

HomeVC: Automatically scrollback to the left every time the screen is…
This commit is contained in:
manuroe 2017-06-08 08:37:55 +02:00 committed by GitHub
commit c2dc1cdc2e

View file

@ -72,6 +72,8 @@
recentsDataSource.areSectionsShrinkable = NO;
[recentsDataSource setDelegate:self andRecentsDataSourceMode:RecentsDataSourceModeHome];
}
[self moveAllCollectionsToLeft];
}
- (void)dealloc
@ -84,6 +86,24 @@
[super destroy];
}
- (void)moveAllCollectionsToLeft
{
// Scroll all rooms collections to their beginning
for (NSInteger section = 0; section < [self numberOfSectionsInTableView:self.recentsTableView]; section++)
{
UITableViewCell *firstSectionCell = [self.recentsTableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:section]];
if (firstSectionCell && [firstSectionCell isKindOfClass:TableViewCellWithCollectionView.class])
{
TableViewCellWithCollectionView *tableViewCell = (TableViewCellWithCollectionView*)firstSectionCell;
if ([tableViewCell.collectionView numberOfItemsInSection:0] > 0)
{
[tableViewCell.collectionView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] atScrollPosition:UICollectionViewScrollPositionLeft animated:NO];
}
}
}
}
#pragma mark - Override RecentsViewController
- (void)displayList:(MXKRecentsDataSource *)listDataSource