I want to pass values from a segmented controller in one view controller to another. I found another question about this, but i don’t understand how to actually implement the delegate method. (original question: Passing UISegmentedControl values from FlipSideViewController in an Utility application to the mainviewcontroller… )
FlipsideViewController.h
@protocol FlipsideViewControllerDelegate;
-(void)flipsideViewControllerSelectionChangedToIndex:(int)index;
@interface FlipsideViewController : UIViewController {
id <FlipsideViewControllerDelegate> delegate;
IBOutlet UISegmentedControl *mapType_;
}
@property (nonatomic, retain) UISegmentedControl *mapType_;
@end
MainViewController.h
@interface MainViewController : UIViewController <XXXX> {
}
@property (nonatomic, retain) UISegmentedControl *mapType;
@end
MainViewController.m
-(void)flipsideViewControllerSelectionChangedToIndex:(int)index {
if (index == 0) mapView.mapType = MKMapTypeStandard;
if (index == 1) mapView.mapType = MKMapTypeSatellite;
if (index == 2) mapView.mapType = MKMapTypeHybrid;
}
How do I call the method in the MainViewController???
-(void)flipsideViewControllerSelectionChangedToIndex:(int)index {
Very thankful for any answers.
Thanks in advance.
your utility view controller needs a pointer to the delegate
so
then in your utility view controller has a IBAction when the view changes and calls the delegate