user301212
user301212

Reputation: 311

how to use UISegmentedControl to change datasource in tableview

how to use UISegmentedControl to change datasource in tableview? with sql tables or read data from arrays thanks

Upvotes: 2

Views: 1008

Answers (1)

kennytm
kennytm

Reputation: 523274

  1. Use -addTarget:action:forControlEvents: (with events UIControlEventValueChanged) to set up a response action for the segmented control.
  2. In the action, check the sender's selectedSegmentIndex property. Use this to determine which data source to use.
  3. Change the table view's dataSource property.

Upvotes: 3

Related Questions