【发布时间】:2021-10-06 05:33:08
【问题描述】:
我需要在 viewcontroller 中显示 containerview,所以我采用了一个 viewcontroller 并进行了设计,并且我将下面的一个 containerview 放到了按钮视图中
给定containerview 约束:在按钮视图下方
top = buttonview.bottom 10, leading, trailing, bottom = 0
有两个按钮用绿线表示..最初我在带有红色按钮的“viewproposalvc”中..如果我点击灰色按钮,那么我需要显示容器视图
这里是viewproposalvc 代码:
class ViewProposalVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
var postId: Int?
@IBOutlet weak var containerView: UIView!
override func viewDidLoad() {
super.viewDidLoad()
updateNavigationBar(with: "View Proposal")
containerView.isHidden = true
}
@IBAction func grayBtn(_ sender: Any) {
containerView.isHidden = false
let vc = UIStoryboard.init(name: "Main", bundle: Bundle.main).instantiateViewController(withIdentifier: "ContainerVC") as? ContainerVC
vc.serviceId = self.viewproposalData?.result?.posted_services?.id
self.navigationController?.pushViewController(vc!, animated: true)
}
@IBAction func redBtn(_ sender: Any) {
containerView.isHidden = true
postedServicesCall()
}
}
这是 containervc 代码:
class ContainerVC: UIViewController, UITableViewDelegate, UITableViewDataSource {
override func viewDidLoad() {
super.viewDidLoad()
}
}
但是这里的 containervc 没有出现在按钮视图的下方.. 它出现在单独的视图控制器中,为什么?
容器vc的o/p:我不想要单独的视图控制器..我需要containervc在下面显示viewproposalvc的按钮视图
我第一次使用容器视图,请帮忙
【问题讨论】:
标签: swift button containers viewcontroller