iOS 8 後,UIActionSheet 與 UIAlertView 可整合為 UIAlertController。它以 controller 方式呈現,生命週期與彈出流程更容易掌握。
使用 alertControllerWithTitle:message:preferredStyle: 建立,再以 addAction 加入按鈕。每個 action 可設定 title、style 與 handler。
常見樣式包含 Default、Cancel、Destructive。Cancel 通常用於取消操作,Destructive 用於刪除等破壞性動作。
建立完成後,呼叫 presentViewController:animated:completion: 顯示。若目前已有其他 modal,需注意呈現順序,避免畫面覆蓋或無法關閉。