首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >ios5 -带有情节提要的模式视图控制器的大小

ios5 -带有情节提要的模式视图控制器的大小
EN

Stack Overflow用户
提问于 2011-11-08 23:25:37
回答 3查看 12.9K关注 0票数 15
  1. 是否有办法调整已使用情节提要段以模态方式显示的视图控制器的大小?
  2. 如何使用翻转过渡从此模式视图控制器显示另一个视图控制器?

如果我把它定义为Style=Modal,Presentation=Default,Transition=Flip,它看起来很奇怪(背景是白色的)。

谢谢!

EN

回答 3

Stack Overflow用户

发布于 2011-11-26 07:41:25

是。在界面构建器中选择视图控制器,然后在属性检查器中将大小设置为自由形式(从推断)。然后选择视图并将其测量值设置为所需的任何值。需要注意的重要一点是,在视图控制器中取消选中Resize View From NIB,否则视图将再次全屏显示。

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

希望这能有所帮助。

票数 34
EN

Stack Overflow用户

发布于 2013-07-21 01:25:14

您可以使用自定义UIStoryboardSegue调整以模式显示的视图的大小。在故事板中,将segue设置为Custom而不是Modal。在Segue类中,为它指定您的UIStoryboardSegue重写的名称。

要覆盖UIStoryboardSegue,您的.h文件中不需要任何内容。它将看起来像这样:

MyStoryboardSgue.h:

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

在MyStoryboardSgue.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
票数 5
EN

Stack Overflow用户

发布于 2012-04-19 23:13:13

我也在试着做同样的事情,在storyBoard中我的ModalView更小,但在模拟器中它覆盖了所有的屏幕……

我认为这在iPhone中是做不到的。(我已经在iPad中做了一个简单的测试,并且模式视图可以工作)。

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

希望这能有所帮助。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8052787

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档