Hi Everyone! Sorry for the constant questions, but in my app, you are able to toggle if 3 UILabels and 1 UIImageview's hidden property is YES or NO via UISwitchs on another page (The settings page). The weird part is, one of the UILabels is hidden, even when it is declared that it is not to be hidden. Here is my code on the settings page.
- (IBAction)changeswitch1 {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (artworkswitch.on)
[prefs setInteger:1 forKey:@"AWKey"];
else
[prefs setInteger:0 forKey:@"AWKey"];
}
- (IBAction)changeswitch2 {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (titleswitch.on)
[prefs setInteger:1 forKey:@"TKey"];
else
[prefs setInteger:0 forKey:@"TKey"];
}
- (IBAction)changeswitch3 {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (artistswitch.on)
[prefs setInteger:1 forKey:@"AKey"];
else
[prefs setInteger:0 forKey:@"AKey"];
}
- (IBAction)changeswitch4 {
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
if (volumeswitch.on)
[prefs setInteger:1 forKey:@"VKey"];
else
[prefs setInteger:0 forKey:@"VKey"];
}
All of this is set as the 'value changed' action in IB for the 4 switches.
Here is the code for the main page
if ([prefs integerForKey:@"AWKey"] == 1)
currentArtwork.hidden = NO;
else if ([prefs integerForKey:@"AWKey"] == 0)
currentArtwork.hidden = YES;
if ([prefs integerForKey:@"TKey"] == 1)
currentSong.hidden = NO;
else if ([prefs integerForKey:@"TKey"] == 0)
currentSong.hidden = YES;
if ([prefs integerForKey:@"AKey"] == 1)
currentArtist.hidden = NO;
else if ([prefs integerForKey:@"AKey"] == 0)
currentArtist.hidden = YES;
if ([prefs integerForKey:@"VKey"] == 1)
volumeview.hidden = NO;
else if ([prefs integerForKey:@"VKey"] == 0)
volumeview.hidden = YES;