TKAlertController 支持 UIAlertView (或 UIActionSheet) 和 UIAlertController。
UIAlertController
显示时,ViewWillDisapper:
不被调用。(但在 TKAlertController
中被调用。)TKAlertController
,就像 UIAlertController
。UIViewController *alertController =
[TKAlertController alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:TKAlertControllerStyleAlert];
TKAlertControllerStyleAlert
是 UIAlertContollerStyleAlert
的替代品。
和 TKAlertControllerStyleActionSheet
是 UIAlertControllerStyleActionSheet
的替代品。
TKAlertAction
作为 UIAlertAction
。TKAlertAction *cancelAction =
[TKAlertAction actionWithTitle:kButtonTitleCancel
style:TKAlertActionStyleCancel
handler:^(TKAlertAction *action) {
// something to do.
}];
TKAlertAction *OKAction =
[TKAlertAction actionWithTitle:kButtonTitleOK
style:TKAlertActionStyleDestructive
handler:^(TKAlertAction *action) {
// something to do.
}];
[alertController addAction:cancelAction];
[alertController addAction:OKAction];
[self presentTKAlertController:alertController animated:YES completion:^{
//
}];
presentTKAlertController:animated:completion:
在 UIViewController 的类别中。
MIT