gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 07:15:02 24 4
gpt4 key购买 nike

我有一个使用自定义 segue 的自定义 tabBar 应用程序,但在 destinationViewController 的大小上存在问题,它总是以全屏<加载/strong> 而不是我在属性检查器中定义的大小。

我在 Simulated Metrics 中将 ViewController 的大小设置为 Freeform,在 Simulated Size 吃了 Size Inspector,我将宽度定义为 1024,将高度定义为 693。我还取消选中了 Resize View from < strong>NIB 即使我没有使用 .xib 文件。

我已经在模拟器和真实设备上测试了这个项目,但是不工作。

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

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

Attributes Inspector

Size Inspector

First ViewController

Segued ViewController

最佳答案

终于找到解决办法了。问题实际上出在我以这种方式使用的 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)
}

现在一切正常!!!

关于swift - 无法使用自定义 segue 和 Storyboard 调整 UIViewController 的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26692384/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com