對不起的問題,但在我的應用程序,你可以切換,如果3 UILabels和1 UIImageview的隱藏屬性是通過另一個頁面(設置頁面上的UISwitchs YES或NO)。奇怪的是,UILabel中的一個是隱藏的,即使它被聲明爲不被隱藏。這是我在設置頁面上的代碼。 奇怪的UISwitch/UILabel.hidden/UIImageView.hidden問題!
- (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"];
}
所有這些設置爲IB中4個開關的'值更改'操作。
下面是主頁
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;
不,沒有另一個標籤在前面...感謝您的快速回復,但! – Flafla2 2010-02-18 03:17:40