Итак, у меня была эта проблема какое-то время, и если кто-то может привести меня на правильный путь, я бы очень признателен. В основном я создаю приложение, но с кнопкой настроек. Всякий раз, когда я включаю свой SegmentedControl или UISWITCH, я возвращаюсь обратно к нему по умолчанию. Кроме того, я хочу иметь элемент управления Segmented для изменения цвета. Я установил цвета, но вся информация, которую я хочу изменить, находится на контроллере # 1. В основном, как сделать страницу настроек, чтобы сохранить изменения. до сих пор мой код.Передача данных через ViewControllers - Сделать страницу настроек
- (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 the 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 the 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 the 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 the selected
NSDictionary *fontColor = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, nil];
[Controller setTitleTextAttributes:fontColor forState:UIControlStateSelected];
}
}
Теперь, как вы можете увидеть «appTitle» находится на первом контроллере представления, поэтому он автоматически не работает. Как я могу это исправить. пожалуйста, соедините меня где-нибудь/покажите мне не сложно. (У меня тоже будет много меток)