gpt4 book ai didi

ios - Swift 3 - 如何防止实例化 View Controller 的背景消失在选项卡和导航栏后面?

转载 作者:行者123 更新时间:2023-11-30 12:37:50 25 4
gpt4 key购买 nike

我使用的是 Swift 3、Xcode 8.2。

我有一个带有导航 Controller 和连接的 TableView Controller 的 Storyboard。该表的单元格在单击时链接到我每次实例化的自定义 TableView Controller 。

let detailVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "dvc") as! ResultsVC
detailVC.view.backgroundColor = UIColor.white
detailVC.edgesForExtendedLayout = [];

但是这个新创建的 VC 的背景似乎消失在顶部导航栏和底部标签栏后面,因为它的颜色发生了变化。如何防止这种情况发生?

最佳答案

这是预期的行为(我假设您正在使用导航 Controller 推送新实例化的 VC)。如果您的 View 隐藏在导航栏后面,请执行以下两件事之一:1)更改新 VC View 的框架,使 y 坐标等于导航栏的高度,或 2)从 IB 推送 View ,而不是在代码中,这将为您处理。

关于ios - Swift 3 - 如何防止实例化 View Controller 的背景消失在选项卡和导航栏后面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42638006/

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