我正在快速學習并嘗試將變數傳遞給作業表,但是當作業表彈出時它并沒有改變變數,有沒有不同的方法可以做到這一點?
let bottomSheet = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "bottomSheet")
if let sheet = bottomSheet.sheetPresentationController{
sheet.detents = [.medium()]
sheet.prefersGrabberVisible = true
sheet.preferredCornerRadius = 24
sheet.prefersGrabberVisible = true
}
bottomSheet.isEnabled = true
self.present(bottomSheet, animated: true, completion: nil)
在bottomSheet視圖控制器中我有變數
var isEnabled: Bool = false
但即使我設定為真,它也總是顯示為假。
編輯:如果您投反對票,請解釋原因,我已經搜索了所有 SO 和 Google 的答案。
uj5u.com熱心網友回復:
像這樣嘗試,您需要做的就是將其指定為視圖控制器。
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
if let bottomSheet = mainStoryboard.instantiateViewController(withIdentifier: "bottomSheet") as? BottomSheetVC{
if let sheet = bottomSheet.sheetPresentationController{
sheet.detents = [.medium()]
sheet.prefersGrabberVisible = true
sheet.preferredCornerRadius = 24
sheet.prefersGrabberVisible = true
}
bottomSheet.isEnabled = true
self.present(bottomSheet, animated: true)
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/438141.html
