using segmented controller

I have added a segment controller in the navigation bar. The segment controller has 3 segments. The first one is "My Schedule", "Others Schedule", "Options".
So when the app is loaded the "My Schedule" is selected by default. It shows a tableview with 10 cells. When any one of the cell is clicked, it navigates to a second page with the detailed information of the schedule.

Similarly, when the second segment is clicked, it should show the "Others schedule" with a similar navigation view.

Could anyone help me understand or provide an example to connect the segmented controller to a table view..?

It sounds like you want tab bar functionality. However, you can create the same functionality with UISegmentedControl. Like all the other UIControl elements (like UIButton or UISwitch), it uses the target: action: forEvent: method of UIControl to respond to user actions.

Therefore when you set up your segmented control, you will set up a method that is called every time the user selects one:

- (void)segmentedControlWasTapped:(id)sender {
// then use a switch statement or series of if statements to determine which selectedSegmentIndex was touched to control the views
if (selectedSegmentIndex == 0) {
// display view controller 1, etc
}
}

I think u must have written action method to be called on taping segment.In that method u can just check the selected segmen Index.For "My shedule" it will be 0,"Others Schedule" it will be 1,"Options" it will be 2.
So in action method you Can just call reloadData method on the tableView you are using.

Thanks for explaining me the details about the segmented control. Thanks for the piece of code Johnny.

I will also try to use the tab bar controller functionality. Initially, I thought that the tab bar functionality was only for the options positioned on the bottom part of view. But if I can use it to create options on the top part of the view; its great to know that.

Thanks for explaining me the details about the segmented control. Thanks for the piece of code Johnny.

I will also try to use the tab bar controller functionality. Initially, I thought that the tab bar functionality was only for the options positioned on the bottom part of view. But if I can use it to create options on the top part of the view; its great to know that.

Tc,
-P

Click to expand...

Well, technically, you can position a tab bar at any position on the screen. But I have only ever seen at the bottom, and I would image that this is where Apple would expect it to be. But I could be wrong.

I was suggesting that if you use a tab bar you should have it at the bottom of the screen. But if that interferes with a toolbar that you might have, then the segmented control at the top would be fine instead.

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.