I have a segmented control with 2 buttons set as the right side button. When I tap either of these buttons the navigation bar slides to the new view and the back button displays correctly, but then immediately slides again as if I were pushing another view on to the stack. For example if I am going from the People view to the Prefernces view, The back button goes like this...
People -> Preferences.
The proper view displays but the didDisplay delegate method does not fire. If I then click the back button which says Preferences, it slides back to a People button and the didDisplay delegate fires. Clicking the People button properly takes me back where I started.
My code looks like this...
Not sure where to start in figuring out this one. Maybe someone can point me in the right direction.
Thanks.
John
People -> Preferences.
The proper view displays but the didDisplay delegate method does not fire. If I then click the back button which says Preferences, it slides back to a People button and the didDisplay delegate fires. Clicking the People button properly takes me back where I started.
My code looks like this...
Code:
//Code to create the buttons
segmentedControl = [ [ UISegmentedControl alloc ] initWithItems: nil ];
segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
[ segmentedControl insertSegmentWithTitle: @"Prefs" atIndex: 0
animated: NO ];
[ segmentedControl insertSegmentWithTitle: @"Add" atIndex: 1
animated: NO ];
[ segmentedControl addTarget:self
action:@selector(segmentedControlPressed:)
forControlEvents:UIControlEventValueChanged ];
UIBarButtonItem *segmentItem = [[UIBarButtonItem alloc]
initWithCustomView:segmentedControl];
[segmentedControl release];
self.navigationItem.rightBarButtonItem = segmentItem;
[segmentItem release];
[self.navigationItem setHidesBackButton:YES animated:YES];
self.navigationItem.leftBarButtonItem = self.editButtonItem;
Code:
//code that pushes the view after clicking the prefs button in the segmented control
self.navigationController.navigationBarHidden = NO;
PrefsViewController *prefsViewController = [[[PrefsViewController alloc]
initWithNibName:@"PrefsViewController" bundle:nil] autorelease];
[self.navigationController pushViewController:prefsViewController
animated:YES];
prefsViewController.view.backgroundColor = self.view.backgroundColor;
Not sure where to start in figuring out this one. Maybe someone can point me in the right direction.
Thanks.
John