 
         NSNotificationCenter.defaultCenter().addObserver(self, selector: "syncFriendships", name: FriendsInContactsViewController.Notification.NewFriends, object: nil)
 
-
-        searchController = UISearchController(searchResultsController: nil)
-
-        searchController.searchResultsUpdater = self
-        searchController.dimsBackgroundDuringPresentation = false
-
-        searchController.searchBar.delegate = self
-        searchController.searchBar.sizeToFit()
-
-        contactsTableView.tableHeaderView = searchController.searchBar
+        // 超过一定人数才显示搜索框
+
+        if friends.count > Int(Ruler.match(.iPhoneHeights(6, 8, 10, 12))) {
+
+            let searchController = UISearchController(searchResultsController: nil)
+
+            searchController.searchResultsUpdater = self
+            searchController.dimsBackgroundDuringPresentation = false
+
+            searchController.searchBar.delegate = self
+            searchController.searchBar.sizeToFit()
+
+            contactsTableView.tableHeaderView = searchController.searchBar
+
+            self.searchController = searchController
+        }
 
         contactsTableView.separatorColor = UIColor.yepCellSeparatorColor()
         contactsTableView.separatorInset = YepConfig.ContactsCell.separatorInset

extension ContactsViewController: UITableViewDataSource, UITableViewDelegate {

    func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return searchController.active ? Int(filteredFriends.count) : Int(friends.count)
    }

    private func friendAtIndexPath(indexPath: NSIndexPath) -> User? {
        let index = indexPath.row
        let friend = searchController.active ? filteredFriends[safe: index] : friends[safe: index]
        return friend
    }



    func searchBar(searchBar: UISearchBar, textDidChange searchText: String) {

        if let searchController = searchController {
            updateSearchResultsForSearchController(searchController)
        }
    }
}

