I have created an up/down arrow segmented control button on the right side of the navigation bar in my detail view. How can I use these up/down arrows to change views?
+1
A:
[mySegmentedControl addTarget:self action:@selector(mySegmentedControlTapped:) forControlEvents:UIControlEventValueChanged];
...
- (void) mySegmentedControlTapped:(id)sender {
NSUInteger selectedOption = mySegmentedControl.selectedSegmentIndex;
if (selectedOption == upArrowIndex) {
// swap in "up"-ward view controller
}
else if (selectedOption == downArrayIndex) {
// swap in "down"-ward view controller
}
}
Alex Reynolds
2010-05-16 00:30:12
Thanks Alex, Below did the trick. if (segmentedControl.selectedSegmentIndex == 0) { Week0 *page = [[Week0 alloc] initWithNibName:@"Week0" bundle:nil]; [[self navigationController] pushViewController:page animated:YES]; page.title = NSLocalizedString(@"Week 0",@""); [page release]; } else if (segmentedControl.selectedSegmentIndex == 1) { Week1 *page = [[Week1 alloc] initWithNibName:@"Week1" bundle:nil]; [[self navigationController] pushViewController:page animated:YES]; page.title = NSLocalizedString(@"Week 1",@""); [page release]; }
Goods
2010-05-16 00:55:48
You may want to pop the existing view controller, or else you'll be pushing a whole bunch of view controllers onto the navigation stack (which you might want).
Alex Reynolds
2010-05-16 09:44:52