- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag { [[self model] setTransitioning:NO]; [[[[self view]subviews] objectAtIndex:0] removeFromSuperview]; }How can I tell what kind of viewController controls the subview at index 0? If it's a QuizViewController I need to call a function on it.
Thanks in advance.
Good answers. I don't believe I explained enough. This is a all in a view controller that is a view stack. The view controller adds and deletes views manually with an animated transition. I am not using a navigationController and cannot in this particular instance for other reasons.
Sometimes the views I add are simple UIImageViews. Sometimes they are QuizViews. The QuizViews have a QuizViewController because they need internal functionality. Here are the two functions I use to add the views.- (void)loadQuiz:(NSInteger )quizNum
{ if([self quizViewController] != nil) { [self setQuizViewController:nil]; } QuizViewController *quiz = [[QuizViewController alloc] initWithNibName:@"QuizViewController" bundle:nil]; [quiz setUp:quizNum]; [self setQuizViewController:quiz]; [quiz release];
[[self view] addSubview:[[self quizViewController]view]]; [self setSlide1:[[[self view] subviews] objectAtIndex:0]]; [self setSlide2:[[[self view] subviews] objectAtIndex:1]]; [[self slide1] setHidden:NO]; [[self slide2] setHidden:YES]; [self performTransition];
}
- (void)loadImage:(NSString *)slideImage
{
UIImage *tempImg = [UIImage imageWithContentsOfFile:[Utilities localPathForFileName:slideImage]]; UIImageView *temp = [[UIImageView alloc] initWithImage:tempImg]; [[self view] addSubview:temp]; [temp release]; //[topView release]; if ([[[self view]subviews] count] > 2) { //add the 2nd subview //[[[[self view]subviews] objectAtIndex:0] removeFromSuperview]; } [self setSlide1:[[[self view] subviews] objectAtIndex:0]]; [self setSlide2:[[[self view] subviews] objectAtIndex:1]]; [[self slide1] setHidden:NO]; [[self slide2] setHidden:YES]; NSLog(@"%s %d",__FUNCTION__,[[[self view]subviews] count]); [self performTransition];
}
So my question is still, in the animationDidStop function how do I detect if it's a quiz?