Switch statement is not working. Using switch statement to update the views ater timer is invalidated. In switch statement it is supposed to switch views from first to second view but it is not doing so.
@property (nonatomic, assign) NSUInteger viewControl;
@synthesize viewControl;
-(void)playpauseAction:(id)sender
{
if
([audioPlayer isPlaying]){
[sender setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateSelected];
[audioPlayer pause];
[timer invalidate];
} else {
[sender setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateNormal];
[audioPlayer play];
self.timer = [NSTimer scheduledTimerWithTimeInterval:11 target:self selector:@selector(displayviewsAction:) userInfo:nil repeats:NO];
}
}
- (void)displayviewsAction:(id)sender
{
switch(viewControl)
{
case 0:
[self performSelector:@selector(FirstViewController) withObject:nil];
break;
case 1:
[self performSelector:@selector(secondViewController) withObject:nil];
break;
case 2:
[self performSelector:@selector(thirdViewController) withObject:nil];
break;
}
}
-(void)FirstViewController {
FirstViewController *viewController = [[FirstViewController alloc] init];
viewController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:viewController.view];
[self.view addSubview:toolbar];
[viewController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:23 target:self selector:@selector(secondViewController) userInfo:nil repeats:NO];
}
-(void)secondViewController {
SecondViewController *secondController = [[SecondViewController alloc] init];
secondController.view.frame = CGRectMake(0, 0, 320, 480);
[self.view addSubview:secondController.view];
[self.view addSubview:toolbar];
[secondController release];
self.timer = [NSTimer scheduledTimerWithTimeInterval:27 target:self selector:@selector(ThirdviewController) userInfo:nil repeats:NO];
}
Any ideas what is missing in the code.
The switch is over a variable named "viewControl" that doesn't seem to be defined anywhere in the code. You are going to have to give us more information to make a proper answer possible.