2017-09-20 9 views
1

私はGoogleプレイスのボトムスクロールリストを模倣しようとしています。UICollectionViewCell内でUITableViewを操作する(Googleプレイスボトムスクロールリストを模倣する)

GoogleプレイスボトムスクロールリストUIをよりよく理解するために、以下の画像を参照してください Google Places Bottom Scrolling List UI

各UICollectionViewCellはのUITableViewを含むと私は、水平スクロールUICollectionViewを作成している My UI

私のUI、

私は各tableviに関連するデータを含む配列を持っていますew。 indexPath.rowをarrayIndexとして使用して、UICollectionViewDelegateメソッド[cellForRow at:indexPath:]の間にtableViewにデータをロードしています。しかし、私はいくつかのtableViewsが同じデータを持って参照してください。

各UICollectionViewCellを追跡し、関連するデータのみをUICollectionViewCell内のそのテーブルビューにロードする方法を知りたいと思います。

答えて

0

collectionViewプリフェッチを使用しないように注意してください。

if (collectionView.responds(to: #selector(setter: 
UICollectionView.isPrefetchingEnabled))) { 

    collectionView.isPrefetchingEnabled = false 

} 

tableViewsを再利用しないことをお勧めします。

func collectionView(_ collectionView: UICollectionView, 
cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 

    let cell = collectionView.dequeueReusableCell(withReuseIdentifier: 
"YourCellIdentifier", for: indexPath) 

    let tableView = tableViews[indexPath.item] 
    tableView.data = dataArray[indexPath.item]; 

    tableView.removeFromSuperview() 
    cell.contentView .addSubview(tableView) 
    tableView.frame = cell.contentView.bounds 

    return cell 

} 
関連する問題