TKAlertController 0.0.4

TKAlertController 0.0.4

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布最新发布2014年12月

KITAGAWA Tatsuya 维护。



  • 作者
  • kitagawa

TKAlertController 支持 UIAlertView (或 UIActionSheet) 和 UIAlertController。

关于

  • TKAlertController 是针对 iOS8 以下的 UIAlertController。
  • 在 iOS8 中,它作为 UIAlertController 运行。
  • 在以前的操作系统版本中,它作为 UIAlertView 或 UIAcitonSheet 运行。
  • 您可以在任何版本中使用它。
  • 它在 Xcode 6beta 和 5x 中都能运行。

已知问题

  • 它不支持 UIAlertView 中的 UITextField 代理。
  • UIAlertController 显示时,ViewWillDisapper: 不被调用。(但在 TKAlertController 中被调用。)
  • 当设备处于警告呈现状态时旋转设备,布局会损坏(冻结先前方向)。

用法

  1. 首先我们创建 TKAlertController,就像 UIAlertController
UIViewController *alertController =
[TKAlertController alertControllerWithTitle:@"title"
                                    message:@"message"
                             preferredStyle:TKAlertControllerStyleAlert];

TKAlertControllerStyleAlertUIAlertContollerStyleAlert 的替代品。

TKAlertControllerStyleActionSheetUIAlertControllerStyleActionSheet 的替代品。

  1. 其次,我们准备 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.
                            }];

  1. 然后,将操作添加到控制器中。
[alertController addAction:cancelAction];
[alertController addAction:OKAction];
  1. 最后,调用显示方法。
[self presentTKAlertController:alertController animated:YES completion:^{
      // 
}];

presentTKAlertController:animated:completion: 在 UIViewController 的类别中。

许可证

MIT