6

在 iOS 5 中它可以正常运行:

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 中无法正常工作,视图不会在屏幕中保持居中,无论是纵向还是横向。有什么解决办法吗?

谢谢!!:)

4

7 回答 7

8

我认为如果您删除UIModalTransitionStyleFlipHorizontal过渡样式并改用其他过渡样式之一,它会起作用。

似乎这是一个错误UIModalTransitionStyleFlipHorizontal

于 2012-10-01T12:37:09.410 回答
3

使用完成:在您的 presentViewController 中:

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

这将使它与UIModalTransitionStyleFlipHorizontal.

于 2012-10-19T11:10:23.113 回答
1

问题是您可以将超级视图的框架设置为您想要的任何内容,但不会更改原点。这就是为什么它不保持居中的原因。

看起来Apple在iOS6中故意限制了这一点

于 2012-09-26T14:35:18.700 回答
1

在我对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]; 
于 2012-12-14T11:45:32.207 回答
1

我成功地完成了以下操作:

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;

UIModalTransitionStyleFlipHorizontal在 ios 6.1 beta 2 上 使用过渡仍然存在问题。aboutSheetFrame是为了避免大小硬编码。

于 2012-12-19T12:32:48.073 回答
0

只需在 viewDidAppear 而不是 viewDidLoad 中执行。你已经排序了!

于 2012-11-23T14:36:06.180 回答
0

对于 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 视图的框架,以使内容的大小正确。

于 2014-01-23T15:08:27.710 回答