ios - Passing Data through ViewControllers - Make settings page -
so i've been having problem while , if can bring me onto right path appreciate it. making app settings button. whenever enable segmentedcontrol or uiswitch, , go back default. want have segmented control change color. have set colors info want change on view controller #1. how make settings page keep changes. heres code far.
- (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]; }
}
now can see "apptitle" on first view controller automatically don't work. how can fix this. please link me somewhere / show me in not complicated way. (i have lots of labels too)
for purpose, use struct declared @ file level (not nested in sort of class). thus, should accessible throughout app. set value when change selected segment; value when loading view controller. here's example in swift:
struct setstruct { var selseg: int = 0 } var settings = setstruct()
in settings view controller viewdidload:
controller.selectedsegmentindex = settings.selseg
in ibaction segmented control:
settings.selseg = controller.selectedsegmentindex
Comments
Post a Comment