Iphone 以编程方式连接两个UIButton
以编程方式将“回放按钮”与“播放按钮”连接。rewindButton只是从开始倒带和播放,playButton从播放切换到暂停。在rewindButton方法中,使用语句在按下UIButton1时更改UIButton2的UIImage。这很好 当按下并暂停播放按钮时,播放按钮方法工作正常。即使在恢复工作后,情况也很好 问题简介: 当按下回放按钮时,它会将playButton的UIImage更改为PauseImage,以便用户可以暂停。恢复暂停时会出现问题<代码>恢复暂停时,它将重新加载视图控制器。它应根据代码仅第一次加载视图控制器Iphone 以编程方式连接两个UIButton,iphone,uibutton,Iphone,Uibutton,以编程方式将“回放按钮”与“播放按钮”连接。rewindButton只是从开始倒带和播放,playButton从播放切换到暂停。在rewindButton方法中,使用语句在按下UIButton1时更改UIButton2的UIImage。这很好 当按下并暂停播放按钮时,播放按钮方法工作正常。即使在恢复工作后,情况也很好 问题简介: 当按下回放按钮时,它会将playButton的UIImage更改为PauseImage,以便用户可以暂停。恢复暂停时会出现问题恢复暂停时,它将重新加载视图控制器。它应根
-(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];
[audioPlayer play];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
[_playButton setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
}
-(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.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;
}
}
}
- (void)displayviewsAction:(id)sender
{
First *first = [[First alloc] init];
first.view.frame = CGRectMake(0, 0, 320, 425);
CATransition *transitionAnimation = [CATransition animation];
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionFade];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionFade];
[self.view addSubview:first.view];
[first release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(Second) userInfo:nil repeats:NO];
}
-(void)Second
{
Second *second = [[Second alloc] init];
second.view.frame = CGRectMake(0, 0, 320, 425);
CATransition *transitionAnimation = [CATransition animation];
[transitionAnimation setDuration:1];
[transitionAnimation setType:kCATransitionReveal];
[transitionAnimation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]];
[self.view.layer addAnimation:transitionAnimation forKey:kCATransitionReveal];
[self.view addSubview:second.view];
[second release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(Third) userInfo:nil repeats:NO];
}
恢复回放方法后重新加载视图控制器的原因我忘记添加isFirstTime==加载视图控制器的是。不需要重新加载ViewController。仅第一次要求ViewController从头开始加载 因此,在倒带方法中设置isFirstTime==YES的值后,它不会从暂停恢复后重新加载视图控制器
-(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];
[audioPlayer play];
if(isFirstTime == YES){
self.timer = [NSTimer scheduledTimerWithTimeInterval:11.0
target:self
selector:@selector(displayviewsAction:)
userInfo:nil
repeats:NO];
isFirstTime = NO;
}
[_playButton setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
}
现在它工作正常。为什么uou要重复你的问题