2015-09-07 57 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 
    } 
}