导航到flipview

时间:2012-12-24 12:56:13

标签: ios uibarbuttonitem uianimation

我在下面的代码中使用了infolight按钮(感谢https://stackoverflow.com/users/630145/ankit-bhardwaj

// This will create ur info button in center.
    UIButton *infoButton = [UIButton buttonWithType:UIButtonTypeInfoLight];
    UIBarButtonItem *infoButtonItem = [[UIBarButtonItem alloc] initWithCustomView:infoButton];
    [infoButton addTarget:self action:@selector(goToRechercherView) forControlEvents:UIControlEventTouchUpInside];
    UIBarButtonItem *flexibleLeft = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
    toolBar.items = [NSArray arrayWithObjects:flexibleLeft,infoButtonItem,flexibleLeft, nil];

这对于动画和&我得到了它如何翻转的部分,但它翻转到同一页面。

//This is for swipe animation. add your view inside.
-(void)goToRechercherView{
    [UIView beginAnimations:@"flipview" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                           forView:self.view cache:YES];
    [UIView commitAnimations];

所以我已将flipviewcontroller.h .m .xib文件添加到项目中,我想在flipanimation中打开该xib / page。

有人建议我使用它的方法。

3 个答案:

答案 0 :(得分:0)

如果您不介意新的视图控制器在演示过程中从右侧而不是左侧翻转,我建议您以模态方式显示新控制器。这很简单:

UIViewController *mySecondViewController = [[self storyboard] instantiateViewControllerWithIdentifier:@"someID"];
[mySecondViewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentViewController:mySecondViewController animated:YES completion:nil];

答案 1 :(得分:0)

试用此代码可能对您有所帮助

-(void)goToRechercherView{

      RechercherView *info3 = [[RechercherView alloc]initWithNibName:@"RechercherView" bundle:nil];
        UINavigationController * nvc = [[UINavigationController alloc] initWithRootViewController:info3];

        info3.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
        [self.navigationController presentModalViewController:nvc animated:YES];

//  if you using latest Version of iOS Just Change the following

  [self.navigationController presentViewController:nvc animated:YES completion:nil];

    }

答案 2 :(得分:0)

有两种方法可以做到这一点......

第一个是......

newView setFrame:CGRectMake( 0.0f, 480.0f, 320.0f, 480.0f)]; //notice this is OFF screen!
[UIView beginAnimations:@"animateView" context:nil];
[UIView setAnimationDuration:0.4];
[newView setFrame:CGRectMake( 0.0f, 0.0f, 320.0f, 480.0f)]; //notice this is ON screen!
[UIView commitAnimations];

第二个选项是使用内置动画作为翻转和卷曲:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
                           forView:newView
                            cache:YES];

[self.navigationController.view addSubview:settingsView.view];
[UIView commitAnimations];