TKAlertController supports both UIAlertView (or UIActionSheet) and UIAlertController.
- TKAlertController is UIAlertController for under iOS8.
- In iOS8, It works as UIAlertController.
- And in previous OS version, It works as UIAlertView or UIAcitonSheet.
- You can use it in same way for any versions.
- It works in both Xcode 6beta and 5x.
- It does not support delegates about UITextField in UIAlertView.
- When
UIAlertController
show,ViewWillDisapper:
is not called. (but inTKAlertController
, it's called.) - Rotate device when alert is presented, layout will broken. (freeze previous orientation)
- First we create
TKAlertController
, asUIAlertController
.
UIViewController *alertController =
[TKAlertController alertControllerWithTitle:@"title"
message:@"message"
preferredStyle:TKAlertControllerStyleAlert];
TKAlertControllerStyleAlert
is insted of UIAlertContollerStyleAlert
.
and TKAlertControllerStyleActionSheet
is instead of UIAlertControllerStyleActionSheet
.
- Second, we prepare
TKAlertAction
asUIAlertAction
.
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.
}];
- then, add action to controller.
[alertController addAction:cancelAction];
[alertController addAction:OKAction];
- finally, call the method to show.
[self presentTKAlertController:alertController animated:YES completion:^{
//
}];
presentTKAlertController:animated:completion:
is in category in UIViewController.
MIT