0

所以我得到了这个按钮,它带有一个if推送到StartViewController. 我NSLog@"transition successful"viewDidLoad这个视图控制器中做了一个检查是否进行了转换。

在日志中显示转换成功,但在屏幕上未进行转换。

这是代码:

-(IBAction)initialButton:(id)sender {
    NSLog(@"initialButton clicked");

   if([userEmail.text length] <4)
   {
       [WCAlertView showAlertWithTitle:@"Email is empty" message:@"You haven't entered an email yet. Please enter one so we can sent you the shipping labels." customizationBlock:^(WCAlertView *alertView) {
           alertView.style = WCAlertViewStyleBlackHatched;
       } completionBlock:^(NSUInteger buttonIndex, WCAlertView *alertView) {
           if (buttonIndex == 0) {
               NSLog(@"Cancel");
           } else {
               NSLog(@"Ok");
           }
       } cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
   }
   else
   {

       StartViewController *startViewController = [[StartViewController alloc] init];
       self.transitionController = [[[TransitionController alloc] initWithViewController:startViewController] initWithNibName:@"StartViewController" bundle:nil];
       [initialViewController.view removeFromSuperview];
       self.window.rootViewController = self.startViewController;

   }


}

这是日志:

2012-12-14 09:22:55.431 Janssenpakketapp[24165:c07] initialViewController loaded
2012-12-14 09:23:04.021 Janssenpakketapp[24165:c07] initialButton clicked
2012-12-14 09:23:06.116 Janssenpakketapp[24165:c07] Ok
2012-12-14 09:23:11.909 Janssenpakketapp[24165:c07] initialButton clicked
2012-12-14 09:23:11.911 Janssenpakketapp[24165:c07] transition succesful
4

2 回答 2

1

新更新:这应该有效:

StartViewController *startViewController = [[StartViewController alloc] init];
    [[UIApplication sharedApplication].delegate.transitionController transitionToViewController:startViewController withOptions:UIViewAnimationOptionTransitionFlipFromRight];
于 2012-12-14T08:39:11.933 回答
1

你想添加过渡动画然后使用下面的代码......

    StartViewController *startViewController = [[StartViewController alloc] init];
    self.window.rootViewController = self.startViewController;
    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];   
    [animation setType:kCATransitionFade];
    [animation setDuration:0.5];
    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:
                                  kCAMediaTimingFunctionEaseInEaseOut]];
    [[self.window layer] addAnimation:animation forKey:@"transitionViewAnimation"];
于 2012-12-14T08:51:16.093 回答