         }
         
         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
         

        configure()
    }
    
    func configure() {
        tapRecognizer =  UITapGestureRecognizer(target: self, action: "tapSelect:")
        selectionEnabled = false
        
        
    }
    
    public func selectTagAtIndex(index:Int) {

        switch align {
        case .Center:
            offset = freeSpace / 2
        case .Right:
            offset = freeSpace
        case .Left:
            offset = 0
        }
        
        offset += (CGFloat(pageIndex) * self.bounds.width)
        var lastFrame = CGRectMake(offset, y, 0, 0)
        
        for addCell in cells {
            addCell.frame = CGRectOffset(addCell.frame, lastFrame.size.width + lastFrame.origin.x + cellInsets.left, y)
            contentView.addSubview(addCell)
            
            lastFrame = CGRectOffset(addCell.frame,  cellInsets.right, 0)
        }
    }
    
    // MARK: - UIScrollViewDelegate
    
    var previousPage = 0
    
    public func scrollViewDidScroll(scrollView: UIScrollView) {
        
        if !(numberOfPages > 1) { return }
        
        let pageWidth = scrollView.bounds.size.width
        let fractionalPage = Double(scrollView.contentOffset.x / pageWidth)
        let currentPage = lround(fractionalPage)
        
        if (previousPage != currentPage) {
            previousPage = currentPage
            
//            bubbleDelegate?.bubbleTagView(self, didChangeCurrentPage: UInt(currentPage))
            pageControl.currentPage = currentPage
        }
    }
    
    // MARK: - IBAction
    
    @IBAction func changePage(sender: UIPageControl) {
        contentView.setContentOffset(CGPointMake(self.bounds.size.width * CGFloat(sender.currentPage), 0), animated: true)
    }
    
    // MARK: - Autolayout
    
    override public func invalidateIntrinsicContentSize() {
        super.invalidateIntrinsicContentSize()
