错误呈现在ipad的iOS居中视图控制器6

问题描述:

在iOS 5中它运行正确:错误呈现在ipad的iOS居中视图控制器6

PinRequiredViewController *pinView = [[PinRequiredViewController alloc]initWithNibName:@"PinRequiredView" bundle:nil]; 

      UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:pinView]; 

      // show the navigation controller modally 
      navController.modalPresentationStyle = UIModalPresentationFormSheet; 
      navController.modalInPopover = NO; 
      navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

      [self presentViewController:navController animated:YES completion:nil]; 

      navController.view.superview.frame = CGRectMake(0, 0, 250, 250); 

      navController.view.superview.center = self.view.window.center; 

但不是在iOS6的工作正常,视图不保持居中于屏幕上,纵向和横向。 任何解决方案?

谢谢! :)

+0

我有同样的问题,无法解决它。用于在iOS 6之前正常工作。 –

+0

@ Javi_576究竟是什么问题?说“不工作”的问题不是对问题的彻底描述。你是说它根本不存在? –

+1

不,视图以iOS5为中心,但在iOS6中没有。 –

限制故意的,我认为,如果你删除UIModalTransitionStyleFlipHorizontal过渡的风格和使用的其他过渡的风格,而不是一个,它会工作。

似乎它是一个UIModalTransitionStyleFlipHorizontal的错误。

+0

谢谢男人!这是一个错误,因为我使用了另一个'UIModalTransitionStyle'并且运行正常! :) –

问题是,您可以将超级视图的框架设置为任何你想要的,但是原点不会被改变。这就是它不保持中心的原因。

它看起来像苹果在iOS6的

+0

感谢您的回复!我以为是... –

使用完成:在您的presentViewController:

[self presentViewController:navController animated:YES completion:^{ 
     navController.view.superview.bounds = CGRectMake(0, 0, 250, 250);}]; 

这将使其与UIModalTransitionStyleFlipHorizontal工作。

+2

这是朝正确的方向迈出的一步,但模态动画是不正确的大小,直到动画完成后。最终的结果是震动。 –

+2

在iOS6上的navCon.view.superview。bounds = CGRectMake(0,0,kPopupsWidth,kPopupsHeight)在presentViewController之后:animated:completion:用于工作,但在iOS7(Beta 5)上不再有效。该视图是调整大小,但不是居中......在完成作品,但动画丑陋地狱! –

只要在viewDidAppear中代替viewDidLoad。你已经整理好了!

在我的理解与UIModalTransitionStyleFlipHorizo​​ntal,唯一的出路是在明年第一线呈现视图,而不动画,设置中心点,后贬,比再次呈现与动画吧:是的。像下面.....

[self presentViewController:navController animated:NO completion:nil]; 

CGPoint centerPoint = CGPointMake([[UIScreen mainScreen] bounds].size.width/2, [[UIScreen mainScreen] bounds].size.height/2); 
navController.view.superview.center = centerPoint; 
[navController dismissModalViewControllerAnimated:NO]; 

navController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentViewController:navController animated:YES completion:nil]; 

我成功有以下几点:

使用 UIModalTransitionStyleFlipHorizontal
aboutViewController.modalPresentationStyle = UIModalPresentationFormSheet; 
aboutViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 

CGRect aboutSheetFrame = aboutViewController.view.frame; 
[self presentViewController:aboutViewController animated:YES completion:^{ 
     aboutViewController.view.superview.bounds = aboutSheetFrame; 
     }]; 
aboutViewController.view.superview.bounds = aboutSheetFrame; 

过渡仍是越野车在iOS 6.1 Beta 2中 aboutSheetFrame是为了避免硬编码的大小。

对于iOS 7试试这个:

[self.navigationController presentViewController:navigationController animated:YES completion:^{ 
    //Make the modal bigger than normal 
    navigationController.view.superview.bounds = CGRectMake(0, 0, 700, 650); 
}]; 

动画看起来会比较难看,所​​以我会建议增加一个动画来改善它:

[self.navigationController presentViewController:navigationController animated:YES completion:^{ 
    [UIView animateWithDuration:0.3 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{ 
     //Make the modal bigger than normal 
     navigationController.view.superview.bounds = CGRectMake(0, 0, 700, 650); 
    } completion:^(BOOL finished) { 
    }]; 
}]; 

还记得,你将需要设置框架viewDidAppear中的navigationControllers视图的内容为正确的大小。