2012-10-26 26 views
0

之前IOS 6我用下面的代码来呈现模态的视图与定制尺寸:变迁大小与presentViewController正确:动画:完成:

- (void) showModalViewWithController:(GUIViewController*) _viewController { 
    [UIView beginAnimations:@"" context:nil]; 
    [self presentModalViewController:_viewController animated:YES]; 
    _viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
    _viewController.view.superview.frame = CGRectMake(
     _viewController.view.superview.frame.origin.x, 
     _viewController.view.superview.frame.origin.y, 
     700.0f, 
     self.view.frame.size.height - 80.f); 
    _viewController.view.superview.center = self.view.center; 

    [UIView commitAnimations]; 
} 

现在我有改变功能

- (void)presentModalViewController: (UIViewController *)viewControllerToPresent animated:(BOOL)flag 

- (void)presentViewController: (UIViewController *)viewControllerToPresent animated: (BOOL)flag completion: (void (^)(void))completion 

不幸的是调整大小后查不正常工作如下所示:

- (void) showModalViewWithController:(GUIViewController*) _viewController { 
    [self presentViewController:_viewController animated:YES completion:^(){ 
     [UIView beginAnimations:@"" context:nil]; 
     _viewController.view.superview.autoresizingMask = UIViewAutoresizingFlexibleHeight; 
     _viewController.view.superview.frame = CGRectMake(
      _viewController.view.superview.frame.origin.x, 
      _viewController.view.superview.frame.origin.y, 
      700.0f, 
      self.view.frame.size.height - 80.f); 
     _viewController.view.superview.center = self.view.center; 
     [UIView commitAnimations]; 
    }]; 
} 

因为模式视图在帧操作之前呈现,并且在调用完成块之后跳转。

如何处理?

由于提前,

米哈尔

+0

发现你试过保持它和以前一样,并留下完成块空白?将所有代码添加到块中应该完全按照您的说法进行操作,呈现视图然后再进行动画演示。 – TheJer

+0

是的,我试图不使用完成块,但它只适用于iOS 5. iOS 6要求额外的屏幕旋转以正确重画视图。 – Kaktusiarz

+0

嗨!任何解决方案我面临同样的问题。谢谢 – Frade

回答

0

我不知道是什么原因结束块动画会跳。我从来没有使用过[UIView beginAnimations:context:]方法。我通常会调用基于块的动画方法,如[UIView animateWithDuration:animations:completion:]。这是因为在iOS 4及以上版本中不鼓励使用beginAnimations方法。

我会尝试改变你的动画来使用基于块的方法。提交动画后可能会出现一些奇怪的线程问题。

我发现它很有趣,你正在调整的大小后显示它,而不是事先调整大小。

0

AHKNavigationController * navigationController = [[AHKNavigationController alloc] initWithRootViewController:moreOverView];

[navigationController setModalPresentationStyle:UIModalPresentationFormSheet];

navigationController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve; 
    navigationController.navigationBarHidden=YES; 
    if([[[UIDevice currentDevice] systemVersion] floatValue] < 8.0) 
    { 
     [self presentViewController:navigationController animated:YES completion:^{ 
      [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
        //Make the modal bigger than normal 
       navigationController.view.superview.frame = CGRectMake(
                     navigationController.view.superview.frame.origin.x, 
                     navigationController.view.superview.frame.origin.y, 
                     540, 
                     622 
                     ); 
      } completion:^(BOOL finished) { 
      }]; 
     }]; 
    } 
    else{ 
     [self presentViewController:navigationController animated:YES completion:nil]; 
     navigationController.preferredContentSize = CGSizeMake(540,622); 
     navigationController.view.superview.center = self.view.center; 
    } 
    navigationController.view.superview.autoresizingMask = 
    UIViewAutoresizingFlexibleTopMargin | 
    UIViewAutoresizingFlexibleBottomMargin; 

其中AHKNavigationController在https://github.com/fastred/AHKNavigationController

相关问题