uiactionsheet deprecated at iOS8


so we have to change uiaction sheet to uialertcontroller


<example at UIViewController>

let alertController = UIAlertController(title: "등록된 혈당측정기를 삭제하시겠습니까?".localized, message: "", preferredStyle: .alert)

        let confirmAction = UIAlertAction(title: "확인".localized, style: .default, handler: { (action) -> Void in

            //do something

        })

        let cancelAction = UIAlertAction(title: "취소".localized, style: .cancel, handler: { (action) -> Void in

            //self.tableView.setEditing(false, animated: true)

        })

        alertController.addAction(confirmAction)

        alertController.addAction(cancelAction)

        self.present(alertController, animated: true, completion: { () -> Void in

            //do something

        })


//handle event selections

func selecttypeitem(action : UIAlertAction){

        var buttonIndex:Int = 0

        for title in self.termTitles {

            if(action.title == title)

            {

                break

            }

            buttonIndex = buttonIndex + 1

        }

}


<example at UIView>

 self.present to use like below

UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: false, completion: nil)


* we cant use sender.tag

* we can use only one action type cancel! if you add multiple cancel action, it will occur exception!

by 무위자연 2017. 12. 4. 11:43
| 1 |