[英]scrolling other UITableview at the same time as another UItableview
我的觀點很復雜。 我基本上有以下幾點
您可以看到我有一個vertical tableview
。 在每個單元格中,我都有一個horizontal tableview
。 我現在想做的是,當我滾動一個horizontal tableview
,其他所有水平桌面視圖也應滾動。
在垂直tableviewCell的子類中,我具有以下內容。
for(HorizontalTableCell *cell in mainTable.subviews){
if([cell isKindOfClass:[HorizontalTableCell class]]){
for(UITableView *cellTable in cell.subviews){
if([cellTable isKindOfClass:[UITableView class]]){
NSLog(@"cell table is table %@",cellTable);
[cellTable setContentOffset:CGPointMake(scrollView.contentOffset.x, 0) animated:NO];
}
}
}
}
但這行不通。 有人可以幫我嗎?
您將需要使用滾動視圖委托方法。 我建議發布一個通知,然后像這樣在單元格中將其接收...
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[[NSNotificationCenter defaultCenter] postNotificationName:@"CellScrolledHorizontally" object:self.tableView];
}
然后,您可以在水平單元格中觀察通知。
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(scrolled:) name:@"CellScrolledHorizontally" object:nil];
- (void)scrolled:(NSNotification *)notification
{
UITableView *notificationTableView = notification.object;
if (notificationTableView == self.tableView)
return;
[self.tableView setContentOffset:notificationTableView.contentOffset];
}
或者,使用UICollectionView
。
您可以嘗試以下邏輯:
可以使用UIScrollView
代替Horizontal tableviews
。 現在,基礎是一個UITableView
,其上具有horizontal scrollviews
。 現在,使用UIScrollview delegate
方法進行事件處理。
雖然這不是解決方案,但您可以查看EASYTABLEVIEW
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.