Hi, Humans!
My name is Hamza Farooq and I love 'Swift' programming. Do check HFSoftUI also... :-)
This extension is used to get top most ViewController in order to show all type of alerts correctly
Do the following simple steps to add this extension in your project and present alerts and action sheets without any inconvenience.
Simply download or copy this code and place it in your project anywhere. I suggest you to make a new file named Extensions.swift and place this code in that file. (Click on the link, this will take you to the directory where extension is placed)
if let topViewController = UIApplication.topViewController() {
topViewController.present(actionSheet, animated: true, completion: nil)
}
- Use Optional Binding just in case if the controller is not found to prevent unintended behaviour of this extension.
- Weather you are using Navigation controller or TabBar controller or simple presented controller, this extension will give the exact controller you want.
I uses this class for my own personal use, if you want to use some other methods or want to modify this class on your own, you can. :-)
Your contributions are most welcomed. Do let me know if you find any kind of issue while using this file. Please open an issue to discuss that problem. Thanks
Hamza Farooq, hamza_faroooq@yahoo.com
MIT (Click Me O_o)