как знать, какие ViewController когда подтаблица удаляется
- (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
{ если ([SELF quizViewController] = NIL!) { [само setQuizViewController: ноль]; } QuizViewController * quiz = [[QuizViewController alloc] initWithNibName: @ "QuizViewController" bundle: nil]; [тест комплектUp: quizNum]; [self setQuizViewController: quiz]; [викторина];
[[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