如何将界面中的按钮与转移到另一个视图相关联?

时间:2012-04-12 18:43:19

标签: objective-c ios

我正在尝试这样做,以便当按下我在xib文件中设置的工具栏中的UIButton时,会将新控制器加载到视图中。

我该如何实现?我试过复制FlipViewController,但我认为你不能有多个这样的。

1 个答案:

答案 0 :(得分:1)

  1. iPad(不要在整个屏幕上使用UINavigationController)。
  2. 您可以使用这样的漂亮动画进行切换: (仅适用于app-delegate,除非您更改用// works only in app delegate注释的行。

    UIViewController *ctrl = [[UIViewController alloc] initWithNibName:@"someXIBStuff" bundle:nil];
    
    
        CAKeyframeAnimation *theAnimation = [CAKeyframeAnimation animation];
        theAnimation.values = [NSArray arrayWithObjects:
                               [NSValue valueWithCATransform3D:CATransform3DMakeScale(1.12,1.12,1)],
                               [NSValue valueWithCATransform3D:CATransform3DMakeScale(1,1,1)],
                               nil];
        theAnimation.cumulative = YES;
        theAnimation.duration = 0.3;
        theAnimation.repeatCount = 0;
        theAnimation.removedOnCompletion = YES;
    
    
        theAnimation.timingFunctions = [NSArray arrayWithObjects:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn], 
                                        nil
                                        ];
    
        [self.window.layer addAnimation:theAnimation forKey:@"transform"];  
    
        CATransition *transition = [CATransition animation];
        transition.duration = 0.3;
        transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
        transition.type = kCATransitionFade;
        transition.delegate = self;
    
        [self.window.layer addAnimation:transition forKey:nil]; 
    
        self.window.rootViewController = ctrl; // works only in app delegate
        [ctrl release];
    
    1. iPhone: 使用UINavigationController(如果可能)。如果没有,您可以使用上面的示例。