是否可以通過編程方式爲UIView
設置viewController
?我想要做的是製作一個總是覆蓋屏幕高度的50%的UIView
,並在初始化後在該view
上添加一個ViewController
。我似乎無法找到一種方法。僞代碼:以編程方式在UIView上設置ViewController
let view = UIView(frame: CGRect(x: 0, y: 0, width: UIScreen.main.bounds.width, height UIScreen.main.bounds.height * 0.5)
//Can't seem to find a method that does exactly this:
view.setViewController(.......)
view.setViewController(.......)在這個地方使用view.addsubview(yourVCname.view) –
@OleAndré所以你想有一個視圖控制器,其中50%被UIView覆蓋,處理由不同的視圖控制器? – Florensvb
相關http://stackoverflow.com/a/42110439/6433023在視圖中添加ViewController –