2016-04-21 5 views
1

Dies ist, was ich in der Lage bin durch ein Tutorial zu machenWie verschiedene Zellgröße in Flow hat

This is the Screenshot of the app

Aber ich muß 1. machen und jede dritte Zelle voller Breite zu sein. Wie soll ich es machen?

Der Code ist diese

class MainViewController: UICollectionViewController 
{ 

    // data source 
    let publishers = Publishers() 

    private let leftAndRightPaddings: CGFloat = 32.0 
    private let numberOfItemsPerRow: CGFloat = 2.0 
    private let heigthAdjustment: CGFloat = 100 

    // MARK: - View controller life cycle 

    override func viewDidLoad() { 
     super.viewDidLoad() 

     let width = (CGRectGetWidth(collectionView!.frame) - leftAndRightPaddings)/numberOfItemsPerRow 
     let layout = collectionViewLayout as! UICollectionViewFlowLayout 
     layout.itemSize = CGSizeMake(width, heigthAdjustment) 
     print(width.description) 

    } 

    // MARK: - UICollectionViewDataSource 

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

    override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 
     return publishers.numberOfPublishers 
    } 

    private struct Storyboard 
    { 
     static let CellIdentifier = "PublisherCell" 
    } 

    override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell 
    { 
     let cell = collectionView.dequeueReusableCellWithReuseIdentifier(Storyboard.CellIdentifier, forIndexPath: indexPath) as UICollectionViewCell 

     return cell} 

} 

Antwort

0

Sie benötigen diese func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize Methode in Ihrer UICollectionViewDelegateFlowLayout

implementieren