- July 26, 2025
- Mins Read
Allow multiple use of presentViewController to UIAlertController.
You may be disappointed from this. Do you imagine that cuckoo spit out some alerts with beatiful animation?
Sorry.
Umm, May be later. But, not now.
This is some codes with swizzle for make UIAlertController multiple using of presentViewController.
You can use CocoaPods to install CuckooAlert
by adding it to your Podfile
:
platform :ios, ‘8.4’
use_frameworks!
pod ‘CuckooAlert’
To get the full benefits import CuckooAlert
wherever you import UIKit
import UIKit
import CuckooAlert
Create a Cartfile
that lists the framework and run carthage update
. Follow the instructions to add $(SRCROOT)/Carthage/Build/iOS/CuckooAlert.framework
to an iOS project.
github “singcodes/CuckooAlert”
CuckooAlert.swift
in your project.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];
seeing Example, ExampleObjc targets on CuckooAlert projects
1.1.0
1.0.1
1.0.0
NavigationKit is a lightweight library which makes SwiftUI navigation super easy to use. 💻 Installation 📦 Swift Package Manager Using Swift Package Manager, add ...
An alternative SwiftUI NavigationView implementing classic stack-based navigation giving also some more control on animations and programmatic navigation. NavigationStack Installation ...
With SwiftUI Router you can power your SwiftUI app with path-based routing. By utilizing a path-based system, navigation in your app becomes ...
This package takes SwiftUI's familiar and powerful NavigationStack API and gives it superpowers, allowing you to use the same API not just ...