I'm starting to develop apps in Xcode 6 with swift. It's my first experience with programming. I'm developing an app that needs to have more than one user interface, and I want to switch between them with a segmented control. Can anybody tell me how to do it? Thanks
Here is an example from one of my projects with an IBAction from the UISegmentedControl using a switch statement for control flow. It was a calculator app. Don't worry about the specific logic. But you can see how to do what you asked. Use each case of the switch statement to segue to a different view.
@IBAction func dateSegmentedControl(sender: UISegmentedControl) {
oneDayArray = []
switch sender.selectedSegmentIndex
{
case 0:
segmentedControlCase = "All"
oneDayArray = historyGameData
self.historyViewTable.reloadData()
break
case 1:
segmentedControlCase = "+"
historyArray(historySign: segmentedControlCase)
case 2:
segmentedControlCase = "-"
historyArray(historySign: segmentedControlCase)
case 3:
segmentedControlCase = "x"
historyArray(historySign: segmentedControlCase)
case 4:
segmentedControlCase = "÷"
historyArray(historySign: segmentedControlCase)
default:
break;
}
}