         }
         
         if currentLine.count > 0 {
-            rows.append(currentLine)
-            rowsWidth.append(currentLineWidth)
-            //  self.addLine(line, cells: currentLine, currentLineWidth : currentLineWidth)
-            
-        } 
-        
-        contentHeight = (dataSource.heightOfTag(self) + self.cellInsets.top + cellInsets.bottom) * CGFloat(rows.count)
-        
-        for i in  0...rows.count - 1 {
-            self.addLine(i, cells: rows[i], currentLineWidth : rowsWidth[i])
-        }
+            if isNewPageRequired() {
+                addNewPage()
+            }
+            
+            // we're done, finish off by adding the last row
+            pages[currentPageIndex].append(currentLine)
+//            rows.append(currentLine)
+            rowsWidth[currentPageIndex].append(currentLineWidth)
+//  self.addLine(line, cells: currentLine, currentLineWidth : currentLineWidth)
+            
+        }
+        
+        // Add all pages of rows of cell views to this view
+        // and update contentHeight
+        for pageIndex in 0..<pages.count {
+            
+            let currentPageHeight = (dataSource.heightOfTag(self) + self.cellInsets.top + cellInsets.bottom) * CGFloat(pages[pageIndex].count)
+            contentHeight = max(contentHeight, currentPageHeight)
+            
+            for lineIndex in  0..<pages[pageIndex].count {
+                self.addLine(lineIndex, ofTagViewCells: pages[pageIndex][lineIndex], currentLineWidth: rowsWidth[pageIndex][lineIndex], toPage: pageIndex)
+            }
+        }
+        
+        
+        numberOfPages = pages.count
+//        print("did reloadData - numberOfpages: \(numberOfPages)")
+        if numberOfPages > 1 {
+            showPageControl(withPageCount: numberOfPages)
+        } else {
+            hidePageControl()
+        }
+        
+        
+        self.contentView.contentSize = CGSizeMake(self.bounds.width * CGFloat(numberOfPages), contentHeight)
         
         self.invalidateIntrinsicContentSize()
         
     }
     
-    func addLine(line : Int, cells : [TagViewCell], currentLineWidth : CGFloat) {
+    func addLine(line : Int, ofTagViewCells cells : [TagViewCell], currentLineWidth : CGFloat, toPage pageIndex: Int) {
         
         let selfWidth = intrinsicContentSize().width
         

        }
    }
    
    public func reloadData() {
        
        
        
        var y : CGFloat = 0
        var line = 0
        
        for subview in subviews {
            subview.removeFromSuperview()
        }
        
        tagViews = []
        
        guard let dataSource = dataSource else {
            contentHeight = 0
            invalidateIntrinsicContentSize()
            return
        }
        
        let selfWidth = intrinsicContentSize().width
        
        var rows : [[TagViewCell]] = []
        var rowsWidth : [CGFloat] = []
        var currentLine : [TagViewCell] = []
        
        

        configure()
    }
    
    override public func layoutSubviews() {
        super.layoutSubviews()
        
        reloadData()
        invalidateIntrinsicContentSize()
    }
    
    func configure() {
        tapRecognizer =  UITapGestureRecognizer(target: self, action: "tapSelect:")
        selectionEnabled = false
        
        contentView.pagingEnabled = true
        contentView.showsHorizontalScrollIndicator = false
        contentView.delegate = self
        
        addSubview(contentView)
        
        contentView.translatesAutoresizingMaskIntoConstraints = false
        let bindings = ["contentView": contentView]
        self.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[contentView]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings))
        let verticalConstraints = NSLayoutConstraint.constraintsWithVisualFormat("V:|[contentView]|", options:NSLayoutFormatOptions(rawValue: 0), metrics:nil, views: bindings)
        self.addConstraints(verticalConstraints)
        self.contentViewToBottomConstraint = verticalConstraints.last!
    }
    
    public func selectTagAtIndex(index:Int) {
