- (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
{ 如果([自quizViewController] =零!) { [自setQuizViewController:無]; } QuizViewController * quiz = [[QuizViewController alloc] initWithNibName:@「QuizViewController」bundle:nil]; [測驗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];
}
所以我的問題仍然是,在animationDidStop功能,我怎樣檢測,如果它是一個測試嗎?
很好的答案。我不相信我足夠的解釋。 – intomo 2010-12-11 06:58:57
謝謝。這工作。 – intomo 2010-12-11 21:28:11