2017-10-12 105 views
0

請參閱鏈接UIAlertController - add custom views to actionsheet 我的UI佈局。取消按鈕在自定義操作表中不可點擊

我在我的應用程序中具有相同的自定義操作表佈局。代碼以相同的方式寫入。我注意到,在swift4中,「取消」按鈕不會執行任何操作。當我在挖掘代碼「取消」按鈕下方

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: {(alert: UIAlertAction!) in 
    print("Cancel") 
}) 

代碼:print(Cancel")不執行。

+0

它不打印取消? –

+0

它可以完美地適用於我 –

+0

您是否將此操作添加到控制器? –

回答

0

我認爲你有一個自定義視圖框架的問題。
在模擬器上運行你的應用程序,並按下「Debug View Hierarchy」:
enter image description here
之後,你可以檢查視圖幀。

0

試試這個處理程序

UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) -> Void in 
      print("cancel") 
     })) 
相關問題