yatatsu / TKAlertController

UIAlertController for under iOS8
MIT License
12 stars 0 forks source link

TKAlertController


TKAlertController supports both UIAlertView (or UIActionSheet) and UIAlertController.

About

Known issue

Usage

  1. First we create TKAlertController, as UIAlertController.
UIViewController *alertController =
[TKAlertController alertControllerWithTitle:@"title"
                                    message:@"message"
                             preferredStyle:TKAlertControllerStyleAlert];

TKAlertControllerStyleAlert is insted of UIAlertContollerStyleAlert.

and TKAlertControllerStyleActionSheet is instead of UIAlertControllerStyleActionSheet.

  1. Second, we prepare TKAlertAction as 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.
                            }];
  1. then, add action to controller.
[alertController addAction:cancelAction];
[alertController addAction:OKAction];
  1. finally, call the method to show.
[self presentTKAlertController:alertController animated:YES completion:^{
      // 
}];

presentTKAlertController:animated:completion: is in category in UIViewController.

LICENSE

MIT