无法使用自定义segue和Storyboard调整UIViewController的大小

时间:2014-11-01 19:37:15

标签: swift uiviewcontroller resize ios8 xcode-storyboard

我有一个使用自定义 segue 的自定义tabBar应用,其中destinationViewController的大小总是在全屏中加载,而不是我在属性Inspector中定义的大小。

我将ViewController的大小设置为模拟指标中的自由形式,并在模拟大小中设置尺寸检查器我将宽度定义为1024,高度定义为693.我还取消选中 NIB中的调整大小视图即使我没有使用 .xib 文件。

我已经在模拟器和真实设备上测试了该项目,但是无效。

当我点击按钮时,它会显示destinationViewController,但它会隐藏TabBar,这当然不会发生。

图片更好地展示了我所面对的:

Attributes Inspector

Size Inspector

First ViewController

Segued ViewController

1 个答案:

答案 0 :(得分:1)

最后成功找到了解决方案。问题实际上是我使用这种方式的perform()函数:

override func perform() {
    var src = self.sourceViewController as UIViewController
    var dst = self.destinationViewController as UIViewController

    src.presentViewController(dst, animated: false, completion: nil)
}

修复的是我用这个更改了presentViewController行:

override func perform() {
    var src = self.sourceViewController as UIViewController
    var dst = self.destinationViewController as UIViewController

    src.view .addSubview(dst.view)
}

现在一切正常!!!

相关问题