Customised collectionView

1. Construction

    var flowLayOut = UICollectionViewFlowLayout()

    var collectionView: UICollectionView? //must be optional


2. Setting

    Frequently-used properties for flowLayOut

        itemSize, minimumInteritemSpacing, minimumLineSpacing, scrollDirection


    collectionView = UICollectionView(frame: CGRect(...), collectionViewLayout: flowLayOut)

    Frequently-used methods for collectionView

        reloadData()

        deselectItemAtIndexPath()


3. Delegate

    UICollectionViewDataSource, 

    UICollectionViewDelegateFlowLayout


    func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int {}

    func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {}

    func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {}

    func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {

    collectionView.registerClass(myCollectionViewCell.self, forCellWithReuseIdentifier: "myCell")

    var cell = collectionView.dequeueReusableCellWithReuseIdentifier("myCell", forIndexPath: indexPath) as? myCollectionViewCell

    }

    func collectionView(collectionView: UICollectionView, didSelectItemAtIndexPath indexPath: NSIndexPath) {}


4. Nesting

    To nest a collectionView inside a collectionViewCell, do the exact same thing as if the collectionViewCell class is a VC. The only tricky part is passing values between the "big" collectionView and the "small" collectionView. I use customised delegate (refer to another blog about customised delegate).

    



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据题目描述,存在以下多对多关系: - Playlist与Soundtrack之间的关系:一个Playlist可以包含多个Soundtrack,而一个Soundtrack也可以出现在多个Playlist中。这是一个多对多关系,因为一个Playlist可以关联多个Soundtrack,同时一个Soundtrack也可以被多个Playlist使用。 需要注意的是,根据题目要求,Soundtracks的选择对于Playlists是私密的,即每个Playlist的Soundtracks对其他人是不可见的。因此,在数据库设计中需要考虑如何保护这种私密性。 其他关系包括: - Retail Store与CD Album之间的关系:一个Retail Store可以销售多个CD Album,而一个CD Album可以在多个Retail Store中销售。这是一个多对多关系。在数据库设计中,可能需要创建一个中间表来记录Retail Store和CD Album之间的关联关系。 - Artist与Album之间的关系:一个Artist可以拥有多个Album,而一个Album只能属于一个Artist。这是一个一对多关系。 - Customer与Invoice之间的关系:一个Customer可以有多个Invoice,而每个Invoice只能属于一个Customer。这是一个一对多关系。 此外,还有其他一对多关系,例如: - Customer与Registration之间的关系:一个Customer可以进行多次Registration,而每次Registration只属于一个Customer。这是一个一对多关系。 - Staff与Registration之间的关系:一个Staff可以帮助多个Registration,而每个Registration只能由一个Staff来帮助。这是一个一对多关系。 根据题目要求,数据库中还需要包括其他信息,如Artist、Soundtrack、CD Album、Customer、Invoice等的详细信息。具体的数据库设计需要根据需求进一步确定。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值