第一次没有找到具有transitionWithView的动画

时间:2012-05-16 11:38:23

标签: objective-c animation ios5 transitions

我有一个带有SubViewController的UIViewController,当点击它时会有变化。第一次(第一次点击后)下一个代码发现很好。在第一次改变视图但没有动画。

- (void)viewDidLoad 
{
    [super viewDidLoad];
    controlersOfBoxes = [[NSMutableArray alloc] initWithCapacity:kBoxCount];
    controlersOfTableBoxes = [[NSMutableArray alloc] initWithCapacity:kBoxCount];

    for(int i = 0; i < kBoxCount; i++) 
    {
        UIViewController* controller = [[UIViewController alloc] init];
        controller.view.tag=i+1;
        UITapGestureRecognizer* t = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped2:)];
        t.numberOfTapsRequired=1;
        [controller.view addGestureRecognizer:t];
        [self.view addSubview:controller.view];
        [controlersOfBoxes addObject:controller];

        UIViewController* controller2 = [[UIViewController alloc] init];
        controller2.view.tag=i+1;
        UITapGestureRecognizer* t2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapped3:)];
        t2.numberOfTapsRequired=1;
        [controller2.view addGestureRecognizer:t2];
        [controlersOfTableBoxes addObject:controller2];
    }
}

- (void) tapped2: (UITapGestureRecognizer*) g 
{

    int tag=g.view.tag;
    UIViewController* v = [controlersOfBoxes objectAtIndex:tag-1];
    UIViewController* vc2 = [controlersOfTableBoxes objectAtIndex:tag-1];

        [UIView transitionWithView:vc2.view
                          duration:0.5
                           options:UIViewAnimationOptionTransitionFlipFromLeft +  UIViewAnimationOptionShowHideTransitionViews  
                        animations:^
         { 
             [v.view removeFromSuperview];
             [self.view addSubview:vc2.view];

         } completion:nil];

}

0 个答案:

没有答案