我試圖改變一個按鈕的隱藏屬性,這是一個方法來完成(查看一個):的UIButton不更新
:-(void)changeSong:(NSString *)songName {
[[SimpleAudioEngine sharedEngine] playBackgroundMusic:[[NSBundle mainBundle] pathForResource:songName ofType:@"mp3"]];
musicPlaying = YES;
playButton.hidden = YES;
pauseButton.hidden = NO;
}
此法是從另一種觀點認爲所謂的
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
MainMenuController *mainMenu = [[MainMenuController alloc] initWithNibName:@"MainMenu" bundle:nil];
[mainMenu changeSong:[songs objectAtIndex:indexPath.row]];
mainMenu = nil;
[mainMenu release];
[[self navigationController] popViewControllerAnimated:YES];
}
我知道changeSong方法因爲音樂改變而被正確調用。但是,這些項目的隱藏屬性不會更改。我試過調用[self.view setNeedsDisplay];但是這並沒有做任何事情。
感謝
如果你把一個斷點changeSong方法中的playButton.hidden行是playButton nil(0x0),還是具有實際值?如果它是零,你可能只是忽略了將UIButton連接到Interface Builder中的playButton ivar。 – 2011-02-01 17:13:30
該值爲零,如下所示:http://d.pr/7rrU但它在「接口」構建器中已鏈接:http://d.pr/z2B – Denis 2011-02-01 17:42:08