iPhone中的自定义Segue

时间:2012-10-18 09:59:42

标签: iphone objective-c ios xcode

我使用Push导航到不同的页面。如你所知,它总是从右向左移动。我希望它能像这样工作:

1 - 当我点击当前页面左侧的按钮时,它从左到右。

2 - 当我点击当前页面右侧的按钮时,它从右到左。

3 - 当我点击加载当前页面的按钮时,它会变为Up。 (像莫代尔)

这是我尝试实现UIStoryboardSegue并创建自定义Segue:

- (void) perform {

    UIViewController *src = (UIViewController *) self.sourceViewController;
    [src.navigationController popViewControllerAnimated:YES];
}

或:

- (void) perform {

    UIViewController *src = (UIViewController *) self.sourceViewController;
    [UIView transitionWithView:src.navigationController.view duration:0.5
                       options:UIViewAnimationOptionTransitionFlipFromBottom
                    animations:^{
                        [src.navigationController popToViewController:[src.navigationController.viewControllers objectAtIndex:0] animated:NO];;
                    }
                    completion:NULL];
}

但他们并没有以我想要的方式工作。 我希望他们像Push Segue一样工作(我希望viewDidLoad,......再次调用) 你能给我一些帮助吗? (请在答案中分享一些代码)

2 个答案:

答案 0 :(得分:0)

IIViewDeckController就像你想要的那样..

看这个演示..

IIViewDeckController Open Source

IIViewDeck from scoop.it

答案 1 :(得分:0)

这就是我需要做的事情:

-(void)perform {  
   UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
   UIViewController *destinationController = (UIViewController*)[self destinationViewController];                    

   CATransition* transition = [CATransition animation];
   transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
   transition.type = kCATransitionPush;
   transition.subtype = kCATransitionFromLeft; 
   [sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
   [sourceViewController.navigationController pushViewController:destinationController animated:NO];    
}

干杯!