ios5 – 与故事板模式视图控制器的大小

  1. 有没有什么办法来调整模态使用故事板segue提出的视图控制器?

  2. 如何从模态视图控制器以翻转过渡显示另一个视图控制器?

如果我将其定义为Style = Modal,Presentation = Default,Transition = Flip Horizo​​ntal,则看起来很奇怪(背景是白色的)。

谢谢!

是。 在界面构build器中select视图控制器,并在属性检查器中设置大小以自由forms(从推断)。 然后select视图并将其测量值设置为您需要的值。 一个重要的注意点是在视图控制器中取消选中从NIBresize视图,否则视图将变为全屏。

不知道第二个问题,如果背景是唯一的问题,你不能只是设置颜色?

希望这可以帮助。

您可以使用自定义的UIStoryboardSegue调整模态显示的视图。 在故事板中,将segue设置为Custom而不是Modal。 在Segue类中,给它一个UIStoryboardSegue覆盖的名字。

要覆盖UIStoryboardSegue,在.h文件中不需要任何东西。 它会显示为这样的东西:

MyStoryboardSegue.h:

#import <UIKit/UIKit.h> @interface MyStoryboardSegue : UIStoryboardSegue @end 

在MyStoryboardSegue.m中,代码将是:

 #import "MyStoryboardSegue.h" @implementation MyStoryboardSegue - (void)perform { id sourceController = self.sourceViewController; id destinationController = self.destinationViewController; UIView *destinationView = [destinationController view]; CGFloat x, y, w, h; [destinationController setModalPresentationStyle:UIModalPresentationFormSheet]; [destinationController setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; [sourceController presentViewController:destinationController animated:YES completion:nil]; /* You have to present the view first, and then resize it. That's because, as far as I can tell, when you present your view modally, a new view is created that covers the screen in a black semi-transparent mask to give the shadow effect, and a container view is placed in the middle of this view that in turn holds the view you are presenting. Your view automatically resizes to the size of this container view, so that's the view you need to resize to make your view controller appear the size you desire. You must present your modal view first because until you do, the container view doesn't exist. The following code resizes the container view (which is now your modal view's superview) and then resets the position of the container view to the center of the source view that is presenting the modal view so everything looks nice and centered. */ x = destinationView.superview.frame.origin.x; y = destinationView.superview.frame.origin.y; w = 400; // Your desired modal view width h = 400; // Your desired modal view height destinationView.superview.frame = CGRectMake(x, y, w, h); destinationView.superview.center = [[sourceController view] center]; } @end 

我正在尝试做同样的事情,而在storyboard上我的ModalView更小,但是在模拟器中它覆盖了所有的屏幕。

我认为这不能在iPhone中完成…(我做了一个简单的testing在iPad和模态视图工作)。

我将尝试iPhone的半透明视图,不会使用模态视图。

希望这可以帮助。