ios - Create Settings Page - UISegmented -


i creating settings menu app. want use uitableviewcontroller, added in uisegmentedcontrol change color of label (green, blue, red). although works when label on same page segmentedcontroller. aka same .h .m file. want control labels on first view controller. how that? if wanted add in vibrate toggle switch. how can access first view controllers labels second view controllers actions? , making view controller + tableviewcontroller correct way of doing or should different. please help. segmented code.

- (ibaction)colorcontroller:(id)sender {  if (controller.selectedsegmentindex == 0) {      //app title text color      apptitle.textcolor =  [uicolor colorwithred:1.00 green:1.00 blue:0.00 alpha:1.0];      //background color when selected     controller.tintcolor = [uicolor colorwithred:1.00 green:1.00 blue:0.00 alpha:1.0];      //the font of selected     nsdictionary *fontcolor = [nsdictionary dictionarywithobjectsandkeys:                                [uicolor blackcolor],nsforegroundcolorattributename,                                nil];     [controller settitletextattributes:fontcolor forstate:uicontrolstateselected];    } if (controller.selectedsegmentindex == 1) {      //app title text color     apptitle.textcolor = [uicolor colorwithred:0.00 green:0.66 blue:1.00 alpha:1.0];      //background color when selected     controller.tintcolor = [uicolor colorwithred:0.00 green:0.66 blue:1.00 alpha:1.0];      //the font of selected     nsdictionary *fontcolor = [nsdictionary dictionarywithobjectsandkeys:                                [uicolor whitecolor],nsforegroundcolorattributename,                                nil];     [controller settitletextattributes:fontcolor forstate:uicontrolstateselected];  } if (controller.selectedsegmentindex == 2) {      //app title text color     apptitle.textcolor = [uicolor colorwithred:0.98 green:0.22 blue:0.22 alpha:1.0];      //background color when selected     controller.tintcolor = [uicolor colorwithred:0.98 green:0.22 blue:0.22 alpha:1.0];       //the font of selected     nsdictionary *fontcolor = [nsdictionary dictionarywithobjectsandkeys:                                [uicolor whitecolor],nsforegroundcolorattributename,                                nil];     [controller settitletextattributes:fontcolor forstate:uicontrolstateselected]; } if (controller.selectedsegmentindex == 3) {      //app title text color     apptitle.textcolor = [uicolor colorwithred:0.15 green:0.82 blue:0.44 alpha:1.0];      //background color when selected     controller.tintcolor = [uicolor colorwithred:0.15 green:0.82 blue:0.44 alpha:1.0];      //the font of selected     nsdictionary *fontcolor = [nsdictionary dictionarywithobjectsandkeys:[uicolor whitecolor], nsforegroundcolorattributename, nil];     [controller settitletextattributes:fontcolor forstate:uicontrolstateselected];  } 

as can see, "apptitle" on first view controller. , how make state of segmented control stays how clicked on it? resets once back.

implement protocol in required class. add required delegate methods & call based on need. way can resolve issue.

refere tutorial links

apple developer guide

delegation

objective-c & swift both


Comments