2015-09-07 56 views
0

我想添加一個過濾選項,如iPhone聯繫人 - >最近有2個過濾器說全部和錯過。我想要說的是,今天,過去和即將到來。在沒有搜索欄的UITableView中過濾選項

所有可用的示例都在其中使用搜索欄,但我不需要搜索欄。

+0

東西然後用UITextfied,用了字符串類型的用戶如何得到的結果 –

+0

我的tableview在這行我只想把過濾器在那裏,所以如果用戶點擊過去的數據則tableview中可以顯示數據過去,反之亦然。 –

+0

兄弟,過濾器是獨立的標準和搜索是分開的哪一個你需要 –

回答

0

簡單,只需使用3個值的分段控制。 enter image description here

然後將該段連接到值更改上的操作。像這樣

@IBAction func filterTable(sender: UISegmentedControl) { 
    if sender.selectedSegmentIndex == 0 { 
     //User selected today! Filter the table for it 
    } 
    else if sender.selectedSegmentIndex == 1 { 
     //User selected past! Filter the table for it 
    } 
    else { 
     //User selected upcomming! Filter the table for it 
    } 
}