【问题标题】:flip viewController only flips the first time翻转 viewController 只翻转第一次
【发布时间】:2011-05-04 18:08:52
【问题描述】:

我正在翻到背面的信息视图。我让它翻转,我在另一边有一个导航栏,可以让我回到原始视图(当我尝试使用模式时这是一个问题)。

我现在的问题是它只在第一次工作:我点击信息按钮,我翻转到背面。我点击后退按钮,我可以毫无问题地返回。

但是,如果我再次点击该信息按钮,它会推送到信息视图而不是翻转。后翻还是不错的。如果我离开根视图并去其他地方然后回来,它会再次正确翻转。 在我单击信息按钮时调用的方法中:

InfoViewController *controller = [[[InfoViewController alloc] init] autorelease];
[UIView beginAnimations:@"animation" context:nil];
[self.navigationController pushViewController: controller animated:NO]; 
[UIView setAnimationDuration:0.8]; 
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO]; 
[UIView commitAnimations];

感谢您的帮助!

【问题讨论】:

    标签: iphone uiviewcontroller uinavigationcontroller flip commitanimations


    【解决方案1】:

    你在哪里初始化 InfoViewController ? 每次您进入 Root 时,它都会被初始化并正常工作...... 当您单击返回时,它不会...如此简单的修复将在 viewWillAppear 中编写此代码...每次访问视图时都会调用它...

    希望这会有所帮助..

    【讨论】:

    • 谢谢 - 解决了这个问题!不幸的是,它提出了另一个问题,我将单独询问。谢谢!
    【解决方案2】:

    这是一个较新的实现,它使用来自较新 UIView API 的块并依赖于 ARC。

    这就是你推新翻屏的方式:

    InfoViewController *controller = [[InfoViewController alloc] init];
    [self.navigationController pushViewController:controller animated:NO];
    
    
    [UIView transitionFromView:self.view
                        toView:controller.view
                      duration:0.8f
                       options:UIViewAnimationOptionTransitionFlipFromLeft
                    completion:^(BOOL finished) {
    
        // Add completion stuff here
    
    }];
    

    这是解除它的sn-p:

    [self.navigationController popViewControllerAnimated:NO];
    
    [UIView transitionFromView:controller.view
                        toView:self.view duration:0.8f
                       options:UIViewAnimationOptionTransitionFlipFromRight
                    completion:^(BOOL finished) {
    
        // Add completion stuff here
    
    }];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-29
      • 1970-01-01
      • 2022-08-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多