阻止行和列CollectionView滚动

时间:2014-12-09 09:15:50

标签: ios scroll uicollectionview

这是我的代码:

var collectionView: UICollectionView?
var collectionViewSeries: UICollectionView?
override func viewDidLoad() {

    super.viewDidLoad()
    // Year
    let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
    layout.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10)
    layout.itemSize = CGSize(width: 90, height: 120)
    layout.scrollDirection = UICollectionViewScrollDirection.Horizontal
    collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
    collectionView!.dataSource = self
    collectionView!.delegate = self
    collectionView!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "Cell")
    collectionView!.backgroundColor = UIColor.whiteColor()
    collectionView?.scrollEnabled = false

    self.view.addSubview(collectionView!)

    // Series
    let layoutSeries: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
    layoutSeries.sectionInset = UIEdgeInsets(top: 20, left: 10, bottom: 10, right: 10)
    layoutSeries.itemSize = CGSize(width: 90, height: 120)
    layoutSeries.scrollDirection = UICollectionViewScrollDirection.Horizontal
    collectionViewSeries = UICollectionView(frame: self.view.frame, collectionViewLayout: layoutSeries)
    collectionViewSeries!.dataSource = self
    collectionViewSeries!.delegate = self
    collectionViewSeries!.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "cellSeries")
    collectionViewSeries!.backgroundColor = UIColor.whiteColor()
    collectionViewSeries?.scrollEnabled = true
    self.view.addSubview(collectionViewSeries!)
}

我的问题:

我试图通过滚动来阻止第一列和第一行。    这样只有中央细胞才能流动。

这是我想要做的一个例子:

link

由于

1 个答案:

答案 0 :(得分:0)

无法为特定单元格禁用滚动。您可以在Section Header中创建一个类似于Cell 1的UIView。这将按您的意愿工作。

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] init]; //your view 
    return view;
}