I have a UISplitViewController utility type app where each UIViewController handles various calculations. I have a popover with segmented controls that allows the user to set certain options. The problem I have is when saving and reloading the contents of UITextfields and the selected segment index, if the segment control index was saved and is == 1 a valuechanged event is fired off from viewdidload as the state is set from
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
theDepthSegment.selectedSegmentIndex = [[defaults objectForKey:@"updateMe"] intValue];
Is there anyway to prevent valuechanged being fired as the selectedsegment is set in view did load? or maybe someway to determine the difference between touch events versus code
It seems strange this happens, maybe there is another way….
Thank You
Considering the view is just loading, the segmented control doesn’t have a previous value, so it will assume it is indeed being changed and acts accordingly. One way you could potentially get around this is to set up a
BOOLvalue in yourIBActionmethod linked to the segmented control. At the beginning of yourviewDidLoadmethod, saywasLoaded = NO(wherewasLoadedwill need to be declared in your header file). Then you’ll assign yourselectedSegmentIndex. Afterwards, declarewasLoaded = YES. Finally, in yourIBActionmethod, say something like