         
         let nib = UINib(nibName: "BookViewCell", bundle: nil)
         self.tableView.registerNib(nib, forCellReuseIdentifier: BookViewCell.cellId)
+        
+        self.segmentedControl.selectedSegmentIndex = 0
+        self.segmentedControl.addTarget(self, action: #selector(selectedSegmentChanged), forControlEvents: .ValueChanged)
+        
+        self.navigationItem.titleView = self.segmentedControl
     }
     
     override func viewWillAppear(animated: Bool) {

    }
    
    func getBookAtIndexPath(path: NSIndexPath) -> Book {
        let tagName = self.model.nameOfTagAt(index: path.section)
        return self.model.getBookFromTag(tagName, atIndex: path.row)!
    }
    
    func bookChanged(notif: NSNotification) {

            self.model.isLibraryChanged = false
        }
    }
    
    func selectedSegmentChanged() {
        self.tableView.scrollRectToVisible(CGRectMake(0, 0, 1, 1), animated: false)
        self.tableView.reloadData()
    }
}

protocol LibraryViewControllerDelegate {
