MOAlertController 1.1.0

MOAlertController 1.1.0

测试已测试
语言语言 Obj-CObjective C
许可证 MIT
发布日期上次发布2015年6月

Taiki Suzuki 维护。



  • Taiki Suzuki

使用 UIAlertController 时,您无需考虑 iOS7 和 iOS8 之间的间隙!!

MOAlertController 拥有与 UIAlertController 相同的功能,因为它是对 UIAlertController、UIAlertView 和 UIActionSheet 的包装类。

  • 提示框
  • 操作表

iOS7

iOS7

iOS8

iOS8

用法

要运行示例项目,首先克隆仓库,然后从示例目录运行 pod install

对于提示框

MOAlertControllerStyleAlert 设置为 preferredStyle。

    MOAlertController *alertController = [MOAlertController alertControllerWithTitle:@"MOAlertController" message:@"This is MOAlertController." preferredStyle:MOAlertControllerStyleAlert];

    MOAlertAction *action = [MOAlertAction actionWithTitle:@"Cancel" style:MOAlertActionStyleCancel handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action];

    MOAlertAction *action2 = [MOAlertAction actionWithTitle:@"Destructive" style:MOAlertActionStyleDestructive handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action2];

    MOAlertAction *action3 = [MOAlertAction actionWithTitle:@"Default" style:MOAlertActionStyleDefault handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action3];

    [controller presentViewControllerWithCurrentViewController:self];;

对于操作表

MOAlertControllerStyleActionSheet 设置为 defStyleult。

    MOAlertController *alertController = [MOAlertController alertControllerWithTitle:@"MOAlertController" message:@"This is MOAlertController." preferredStyle:MOAlertControllerStyleActionSheet];

    MOAlertAction *action = [MOAlertAction actionWithTitle:@"Cancel" style:MOAlertActionStyleCancel handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action];

    MOAlertAction *action2 = [MOAlertAction actionWithTitle:@"Destructive" style:MOAlertActionStyleDestructive handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action2];

    MOAlertAction *action3 = [MOAlertAction actionWithTitle:@"Default" style:MOAlertActionStyleDefault handler:^(MOAlertAction *action) {
        //Write a code for this action.
    }];
    [alertController addAction:action3];

    [controller presentViewControllerWithCurrentViewController:self];

如果您想取消,请使用此方法。

[controller dismissViewControllerFromCurrentViewController];

要求

  • iOS 7.0 和更高版本
  • ARC

安装

作者

Taiki Suzuki,[email protected]

许可证

MOAlertController 提供 MIT 许可证。有关更多信息,请参阅 LICENSE 文件。