【问题标题】:How can I change size when showing a modal view controller using storyboard?使用情节提要显示模态视图控制器时如何更改大小?
【发布时间】:2012-04-26 21:17:07
【问题描述】:

使用故事板,我使用模态样式和表单演示创建到另一个视图控制器的过渡。但始终具有相同的大小。

如何使用情节提要更改此视图控制器的大小? 我发现了一些几乎可以工作的代码,但我从来没有让 mu modal view controller 居中。 How to resize a UIModalPresentationFormSheet? 请注意,我使用 Storyboard,而该代码不适用于 Storyboard。

您有什么想法或建议吗?

顺便说一句,prepareForSegue os好像叫BEFORE viewDidLoad,这正常吗?

非常感谢您的回复。

【问题讨论】:

    标签: ios5 storyboard modalviewcontroller


    【解决方案1】:

    虽然有点晚了。

    我之前已经实现过它。我已经设法让 UIPresentationFormSheet 居中。 这是我的代码..

    [detailView setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
    [detailView setModalPresentationStyle:UIModalPresentationFormSheet];    
    [self presentModalViewController:detailView animated:YES];
    detailView.view.superview.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
    float heightOfFrame = 200.0f;
    float widthOfFrame= 400.0f;
    detailView.view.superview.frame = CGRectMake(
        self.view.superview.center.x - (widthOfFrame/2),                                         
        self.view.superview.center.y - (heightOfFrame/2),
        widthOfFrame,
        heightOfFrame
    ); 
    

    希望我在某些方面对您有所帮助。

    问候,史蒂夫

    【讨论】:

    • 感谢您的回复。您如何看待使用边界?而且,当呈现的视图是导航控制器时,您是否有问题?使用导航控制器时,这些技巧似乎不起作用。
    【解决方案2】:

    我最近遇到了同样的问题,并且能够使用此属性更改表单视图的大小:

    【讨论】:

      猜你喜欢
      • 2013-06-21
      • 2016-12-16
      • 2011-12-23
      • 2019-07-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-18
      相关资源
      最近更新 更多