How this UIButton rewind can send notification to UIButton play to perform playpauseaction method when rewind button is clicked.
-(void)rewind:(id)sender{
[timer invalidate];
audioPlayer.currentTime = 0;
MainViewController *viewController = [[MainViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self.view addSubview:toolbar];
[viewController release];
}
-(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;
}
}
}
rewind button when clicks perform rewind method and as well send notification to play button to perform playpauseAction method.
Thanks for help.
EDIT
Have declared
@property (nonatomic, retain) UIButton *playButton;
@synthesize playButton = _playButton;
[self playpauseAction:_playButton];
what happening is when clicking on rewind button it performing play pause action method but not toggling play button to pause as per playpauseaction method. why is that
If you have a reference to your play pause button (which you will want to have to make this kind of thing a ton easier), you can just write this line in your
rewindmethodYou don’t need to use the notification center at all