CuckooAlert 1.1.0

CuckooAlert 1.1.0

测试已测试
语言语言 SwiftSwift
许可证 BSD
发布最后发布2016年9月
SPM支持 SPM

Kwanghoon Choi 维护。



CuckooAlert

允许多次使用 presentViewController 来呈现 UIAlertController。


您可能会失望。您想象过会有鸟儿吐出一些带有美丽动画的提示吗?

抱歉。

嗯,可能以后会吧。但现在不会。

这是使用 swizzle 来使 UIAlertController 多次使用 presentViewController 的一些代码。

要求

  • iOS 8.4+
  • Xcode 7.3

安装

手动

  1. 下载并将在您的项目中放下 CuckooAlert.swift
  2. 恭喜!

使用示例

Swift

import CuckooAlert

in AppDeleaget launching

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        CuckooAlert.registCuckooAlert()
        return true
}

in ViewController

        var alert = UIAlertController(title: "title", message: "message", preferredStyle: .Alert)
        let cancel = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil)
        alert.addAction(cancel)
        // present first alert controller
        self.presentViewController(alert, animated: true, completion: nil)

        alert = UIAlertController(title: "title2", message: "message2", preferredStyle: .Alert)
        alert.addAction(cancel)
        // present second alert controller
        self.presentViewController(alert, animated: true, completion: nil)

        if let vc = self.storyboard?.instantiateViewControllerWithIdentifier("2") {
            // This will be ignored with some Warning:
            self.presentViewController(vc, animated: true, completion: nil)
        }

        alert = UIAlertController(title: "title3", message: "message3", preferredStyle: .Alert)
        alert.addAction(cancel)
        // present third alert controller
        self.presentViewController(alert, animated: true, completion: nil)

ObjC

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [CuckooAlert registCuckooAlert];
    return YES;
}

in ViewController

    UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];
    UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"title" message:@"message" preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:cancel];
    // present first alert controller
    [alert showWithParentViewController:self animated:true completion:nil];
    alert = [UIAlertController alertControllerWithTitle:@"title2" message:@"message2" preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:cancel];
    // present second alert controller
    [alert showWithParentViewController:self animated:true completion:nil];

    // This will be ignored with some Warning:
    [self presentViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"2"] animated:YES completion:nil];

    alert = [UIAlertController alertControllerWithTitle:@"title3" message:@"message3" preferredStyle:UIAlertControllerStyleAlert];
    [alert addAction:cancel];
    [alert showWithParentViewController:self animated:true completion:nil];

在 CuckooAlert 项目中查看 Example, ExampleObjc 目标

发布历史

  • 1.0.1
    • 添加对 UIViewController 的提示功能
    • 移除一些调试打印

  • 1.0.0
    • 添加 CuckooAlert.swift
    • 添加 CuckooAlert 类以启用 swizzle
    • 在 UIViewController 上对 viewDidLoad、viewDidDisappear、presentViewController 进行 swizzle 以管理 UIAlertController 呈现队列
    • 添加一些快捷函数到 UIAlertController

贡献

我非常希望您为 CuckooAlert 做出贡献或修改或复制任何内容,有关更多信息,请查看 LICENSE 文件。

元数据

singcodes – @KwanghoonChoi[email protected]

在 BSD(3-clause) 许可下分发。有关更多信息,请参阅 LICENSE

https://github.com/singcodes