0

当用户点击UIButton1(rewind button)要求是改变UIImage其他的UIButton2(playbutton)。我怎样才能做到这一点。

UIButton *rewindButton = [UIButton buttonWithType:UIButtonTypeCustom];
[rewindButton addTarget:self action:@selector(rewind:) forControlEvents:UIControlEventTouchUpInside];
rewindButton.frame = CGRectMake(0, 0, 38, 38);
UIImage *imge = [UIImage imageNamed:@"Rewind Icon .png"];
[rewindButton setImage:imge forState:UIControlStateNormal];
UIBarButtonItem *rewind = [[UIBarButtonItem alloc] initWithCustomView:rewindButton];

-(void)rewind:(id)sender{
audioPlayer.currentTime = 0;
[timer invalidate];
ContainerViewController *viewController = [[[ContainerViewController alloc] init]autorelease];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view]; 
[self.view addSubview:toolbar];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                    target:self
                                    selector:@selector(displayviewsAction:)
                                    userInfo:nil
                                    repeats:NO];
}

//Add Play Button

_playButton = [UIButton buttonWithType:UIButtonTypeCustom];
[_playButton addTarget:self action:@selector(playpauseAction:) forControlEvents:UIControlEventTouchUpInside];
_playButton.frame = CGRectMake(0, 0, 38, 38);
[_playButton setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateNormal];
[_playButton setImage:[UIImage imageNamed:@"52.png"] forState:UIControlStateSelected];
 UIBarButtonItem *play = [[UIBarButtonItem alloc] initWithCustomView:self.playButton];


-(void)playpauseAction:(id)sender {
 if([audioPlayer isPlaying])
{
    [sender setImage:[UIImage imageNamed:@"Play Icon.png"] forState:UIControlStateSelected];
    [audioPlayer pause];
    [self pauseTimer];
    [self pauseLayer:self.view.layer];

}else{
    [sender setImage:[UIImage imageNamed:@"pause icon.png"] forState:UIControlStateNormal];
    [audioPlayer play];
    [self resumeTimer];
    [self resumeLayer:self.view.layer];
   if(isFirstTime == YES)
    {
        self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
                                            target:self
                                            selector:@selector(displayviewsAction:)
                                            userInfo:nil
                                            repeats:NO];
        isFirstTime  = NO;
    }
    } 
    }

当用户点击时,UIButton1(rewind button)要求将UIImage其他的UIButton2(play button)从 play icon.png 更改为 pauseicon.png。

我怎样才能做到这一点。

有任何想法吗。

4

1 回答 1

2

直接设置按钮的图像不起作用吗?

-(void)rewind:(id)sender{
    [_playButton setImage:[UIImage imageNamed:@"pause icon.png"] forState:UIControlStateNormal];
    //...
}
于 2012-07-10T16:26:57.093 回答