【问题标题】:Modal View controller not displaying at Center模态视图控制器不显示在中心
【发布时间】:2014-07-07 12:51:02
【问题描述】:

![我正在开发一个 ipad 应用程序,我必须将表格视图显示为表单,当我单击表格中的单元格时,表单应调整大小][1]

我写了这段代码

-(void)viewWillAppear:(BOOL)animated
{
 self.view.superview.bounds = CGRectMake(0, 0, 290, 620);
}

当单击一个单元格时,我在索引路径处选择行中写了self.view.superview.bounds = CGRectMake(0, 0, 600, 620);。这两次表单都没有显示在中心。我哪里错了。有没有其他方法可以实现这种行为

【问题讨论】:

    标签: objective-c ipad modalviewcontroller


    【解决方案1】:

    在 iOS 7 中,您无法再调整模态显示的视图控制器的大小。

    您想使用 UIModalPresentationStyleCustom 模式,然后使用 iOS 7+ 中可用的新 API 提供您自己的自定义过渡

    查看以下链接了解更多信息:

    http://www.objc.io/issue-5/view-controller-transitions.html
    http://www.teehanlax.com/blog/custom-uiviewcontroller-transitions/
    http://objectivetoast.com/2014/03/17/custom-transitions-on-ios/

    【讨论】:

      【解决方案2】:

      你能提供更多细节吗?基本上,您的表单视图似乎需要正确设置 AutoResizingMasks(示例):

      UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth

      即:

      self.yourContainerView.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleWidth;

      此外,将表单视图中心设置为视图中心也有助于:

      yourformView.center=self.view.superview.center;

      这也将使您的表单位置居中(水平和垂直)。

      希望这可能会有所帮助,不确定您的确切情况,但如果上述答案没有帮助,更多细节可能会有所帮助。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2015-03-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多